码迷,mamicode.com
首页 > Web开发 > 详细

ajax 跨域请求

时间:2017-01-05 01:32:47      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:field   font   json   getjson   on()   pre   this   erro   jquer   

1、

$.ajax({
type: "get",
async: false,
url: "http://61.160.194.208:8383/Api/login?account=api_tcs&password=123456",
dataType: "jsonp",
jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
jsonpCallback:"flightHandler",//自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名,也可以写"?",jQuery会自动为你处理数据
xhrFields: { withCredentials: true },
success: function(json){
// console.log(json)

},
error: function(){
alert(‘fail‘);
}
});

 

function flightHandler(data) {
console.log(data);

}



2、getJson

$.getJSON(‘http://61.160.194.208:8383/Api/login?account=api_tcs&password=123456&callback=?‘,function (data) {
jession= data.jsession;
if(jession){
getHistoryLast(‘13701047694,13717533834,13717534041‘);
}
});

ajax 跨域请求

标签:field   font   json   getjson   on()   pre   this   erro   jquer   

原文地址:http://www.cnblogs.com/zrlhss/p/6250651.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!