Ajax从cordova android应用程序调用localhost中的REST服务,返回
{ "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作为模拟器。