Josnp跨域访问总执行error
发布时间:2020-12-16 18:54:25 所属栏目:百科 来源:网络整理
导读:$.ajax({ url: "http://timer.com/timer1?refresh=" + new Date().getTime(),type: "GET",crossDomain: true,dataType: 'jsonp',async: false,jsonp:'callback' success: function(data){ console.log(err); },error: function (xhr,status,err){ console.lo
$.ajax({ url: "http://timer.com/timer1?refresh=" + new Date().getTime(),type: "GET",crossDomain: true,dataType: 'jsonp',async: false,jsonp:'callback' success: function(data){ console.log(err); },error: function (xhr,status,err){ console.log(err); } });总进入error,是因为返回的json串格式不对,后台必须返回如:xxxxx({"name":"value","name":"value"}) 格式串,其中xxxxx是callback的方法名。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |