I have a rails api running on localhost:3000. On my phonegap app i'm trying to login via api , but it give an error("error") and don't reach to the api. could be some problem with cross domain request, but is said that in the mobile there is no such thing. internet is working .
my ajax:
$.ajax({
url: 'localhost:3000/api/v1/login',
type: "POST",
dataType: "json",
data : {username:"demo",password:"demo"},
success: function(data) {
navigator.notification.alert("ok");
},
error: function(xhr, textStatus, errorThrown) {
console.log("Error status " + status);
}
});
EDIT 2 - solved
You have to to use local ip eg. 192.168.2.2 and add the host in the Cordova.plist in the ExternalHosts key.