I've got a simple server app running on Heroku that I'm making ajax calls to from a Cordova app. I've setup CORS on the server app and I can call the server from my browser without any problems. However, when I call the server using the exact same code from within Cordova I get a Bad Request error!!
$.ajax({
url: 'http://{myserver}/{function}',
type: 'GET',
data: { mydata... },
success: function(resp){ alert("success"); },
error: function(err) { alert(err.statusText); }
});
I've tried adding crossDomain: true
and dataType: 'jsonp'
, it makes no difference. I've also checked that all domains are whitelisted in Cordova <access origin="*" />
Why can't I access the server from Cordova when I can access it from my browser?