jQuery AJAX 跨域请求

时间:2024-03-28 11:34:26

跨域请求 只要 dataType : 'jsonp',  jsonp:"jsoncallback",  然后返回一个json格式的就可以了

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>|体检系统</title>
</head>
<body> <script src="http://cdn.bootcss.com/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $.ajax(
{
type:'get',
url : 'http://www.taobao.com?loginuser=lee&loginpass=123456',
dataType : 'jsonp',
jsonp:"jsoncallback",
success : function(data) {
alert(data)
},
error : function() {
alert('fail');
}
}
);
});
</script> </body> </html>