ajax跨域调用和非跨域调用的写法

前端之家收集整理的这篇文章主要介绍了ajax跨域调用和非跨域调用的写法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//支持跨域调用
	$.ajax({  
		type:"POST",async :false,url:"http://web3.com:9080/authority/dept/hellob.shtml?userName=zqb&callback=?",dataType:"jsonp",success:function(data){  
			//alert(data);
			console.log(data);
		},error:function(){  
		alert("error");  
		}  
		  
		});  

	  
	  }
	  //不支持跨域调用
	  function b(){
		  
		  $.ajax({
		        type: "post",dataType: "html",url: "http://web3.com:9080/authority/dept/hellob.shtml?userName=zqb",data: "",success: function (data) {
		        	console.log(data);
		        }
		    });
		  
	  }
原文链接:https://www.f2er.com/ajax/161245.html

猜你在找的Ajax相关文章