All ajax return 404 with Phonegap 3.0.0 – jQuery 2.0.3-Collection of common programming errors
I have loaded everything required from the documentation to enable internet connectivity but all and any Ajax requests are received with a 404
return code.
I know that the file I am trying to reach is assessable across domain. Seen here: http://jsfiddle.net/hutber/VN864/
I am running this same code inside my app and on click 404
is returned in the alert.
To test my connection I am running:
var networkState = navigator.connection.type;
var states = {};
if(typeof Connection!=="undefined"){
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
This returns the connection as expected. Currently WiFi connection
config.xml
AndriodManiest.xml
JS used to call said http request
$.ajax({
url: 'http://stage.sexdiaries.co.uk/app/users/login',
type: 'post',
data: {
'uname': values.uname,
'pword': values.pword
},
crossDomain: true,
error: function(data){
c(data.status);
},
success: function(data){
c('success: '+data);
data = JSON.parse(data);
if(data.privateKey){
$.jStorage.set('uid',data.ud.uid); //store user ID in the localStorage to persist
sessionStorage.setItem('privateKey',data.privateKey); //store privateKey in session so it disapears when the user closers the tab
Backbone.history.loadUrl('');
}
}
});
So I know that the connection is active. Do I really have a connection? Am I crazy? How can I reach this http request?