Ajax 请求在 Cordova 应用程序 Visual Studio 中失败



我正在使用Visual Studio 2015使用Cordova构建Android应用程序。它在模拟器中工作正常。但是当我发布它时,ajax 请求失败,因为同样的事情适用于 emulator.no 日志中的错误,但只有 ajax 错误。

var url = 'http://oployeelabs.net/demo/demo_doctorola/doctorola-server/index.php/doctor_panel_api/validation_modified/format/json';
load();
$.ajax({
url: url,
data: { cell_no: phone, pass: pass },
method: 'POST',
dataType: 'json',
success: function (data) {
alert();
if (data == "false")
{
alert("Wrong password");
}
else
{
localStorage.doctorid = data[0].id;
localStorage.userinfo = JSON.stringify(data);
$.ajax({
url: "http://oployeelabs.net/demo/demo_doctorola/doctorola-server/index.php/api/information/meta-info/location/id/"+data[0].id+"/username/9791a47fef07649b1c3e70749e898153/password/2d593e25d0560b19fd84704f0bd24049/format/json",
method: 'GET',
dataType: 'json',
success: function (dt) {
localStorage.Chamberinfo = JSON.stringify(dt);
mainView.router.loadPage({ url: 'menu.html', ignoreCache: true, reload: true })
$('.toolbar').removeClass('hide');
}
});

}
//if (data === "ok") {
//    $(".confirm_appointment").remove();
//    var anc = "<a id='confirm_appointment' class='confirm_appointment' style='opacity: 0;' href='confirm.html' data-context='{"slot_id": "" + slot_id + "","slot_date": "" + slot_date + "", "email": "contact@john.doe"}'>profile</a>";
//    $(document).find('.page_content').append(anc);
//    $(".confirm_appointment")[0].click();
//}
//else {
//    myApp.hidePreloader();
//    myApp.alert("", "Sorry, this slot has been booked. Please try with another slot.");
//}
},
error: function (xhr, status, exception) {
alert(xhr.responseText+" "+status+" "+ exception);
console.log("Error: " + xhr.responseText + " - " + exception);
},
complete: function () {
myApp.hidePreloader();
unload();
}
});

奇怪的是,在我卸载白名单插件并再次安装它后,它起作用了。 我不知道为什么,但我认为这是科尔多瓦的错误。

最新更新