手机端jsonp的使用

问题:通过Ajax中的jsonp功能,跨域获取json数据,PC上可以得到,但是手机上无法执行Ajax。换成getJSON,没有响应值。

//已包含JQuery1.7.js
//PC可用,手机端不可用
$.ajax(
{
url: '<?=PC_BUY_INDEX?>index/cars/apply/',
data: {'proId': productId, 'carsId': carsId, 'cityId': cityId, 'sex': sex, 'phone': phone, 'hopePrice': hopePrice, 'realName': realName}, //参数没有问题
type: 'get',
async: false,
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback:'flightHandler',
complete: function (XMLHttpRequest, textStatus){
var data = XMLHttpRequest.responseText;
//alert("responseText:"+data);
//alert('textStatus: ' + textStatus); //PC端输出success
},
success: function (json) {
if (json.success) {
location.href = '/index.php?c=Buy_Apply&a=ApplySuccess&productId=' + productId + '&carsId=' + carsId + '&cityId=' + cityId;
} else {
$("#mch_err").attr('class', "mch_err_show");
$("#mch_err").html(json.message);
}
}
});

求解,手机端如何实现跨域取数据?
...全文
298 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Secret留声机 2015-11-25
  • 打赏
  • 举报
回复
哥们 咋解决的
  • 打赏
  • 举报
回复
解决了,原因:提交的host地址,在手机上无法访问。o(╯□╰)o
  • 打赏
  • 举报
回复
jsonp就是script加载数据而已,手机浏览器也能执行的 还原你服务器端加了手机端的判断什么的,导致输出的js代码有错误

87,984

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧