【发布时间】:2015-07-31 21:50:29
【问题描述】:
从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 作为模拟器。
【问题讨论】:
标签: android ajax json cordova rest