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);
		        }
		    });
		  
	  }

猜你喜欢

转载自skyfar666.iteye.com/blog/2267251
今日推荐