![](/img/trans.png)
[英]First ajax call status 0 “error” but second ajax call status 4 “200”
[英]Ajax call to REST service returns status:0
從Cordova Android應用程序到localhost中REST服務的Ajax調用返回
{ "readyState" : 0, "responseText" : "", "statusText" : "error" }
我已經將<access origin="*" />
到config.xml中
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(dataObject),
url: "http://10.0.3.2:8080/ServiceProject/rest/vsa-service/auth",
success: function(result){
if(result.auth){
window.localStorage["authentication"] = result.authCode;
window.localStorage["authDetails"] = result.details;
$.mobile.changePage("#home");
}
else{
navigator.notification.alert('Login failed. Try again.', function() {});
}
},
error: function(err){
navigator.notification.alert('Error occurred unexpectedly.' + JSON.stringify(err) , function() {});
}
});
我正在使用GenyMotion作為模擬器。
根據此答案,我創建了一個全新的cordova項目,並將www文件夾復制到其中。 然后構建並運行。 AJAX調用工作正常。 沒有對代碼進行任何更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.