jquery - VS2017 Cordova $.ajax XMLHTTPREQUEST 失败
问题描述
该代码在使用浏览器进行测试时有效。但是当我构建和安装apk时失败了。
$.ajax({
type: "POST",
async: true,
url: "http://localhost:60052/Public/Interface.asmx/Test",
data: JSON.stringify(Params),
cache: false,
contentType: "application/json; charset=utf-8",
success: function (msg) {
},
error: function (XHR, errStatus, errorThrown) {
// NETWORKERROR: 'XMLHTTPREQUEST': FAILED TO LOAD ......
}
});
在我的 Cordova 项目中,我已经设置了:
<access origin="*" />
<allow-intent href="http:*" />