{"id":3559,"date":"2014-03-28T10:36:40","date_gmt":"2014-03-28T10:36:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/28\/all-ajax-return-404-with-phonegap-3-0-0-jquery-2-0-3-collection-of-common-programming-errors\/"},"modified":"2014-03-28T10:36:40","modified_gmt":"2014-03-28T10:36:40","slug":"all-ajax-return-404-with-phonegap-3-0-0-jquery-2-0-3-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/28\/all-ajax-return-404-with-phonegap-3-0-0-jquery-2-0-3-collection-of-common-programming-errors\/","title":{"rendered":"All ajax return 404 with Phonegap 3.0.0 &#8211; jQuery 2.0.3-Collection of common programming errors"},"content":{"rendered":"<p>I have loaded everything required from the documentation to enable internet connectivity but all and any Ajax requests are received with a <code>404<\/code> return code.<\/p>\n<p>I know that the file I am trying to reach is assessable across domain. Seen here: http:\/\/jsfiddle.net\/hutber\/VN864\/<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/PkSMp.png\" \/><\/p>\n<p>I am running this same code inside my app and on click <code>404<\/code> is returned in the alert.<\/p>\n<p>To test my connection I am running:<\/p>\n<pre><code>    var networkState = navigator.connection.type;\n\n    var states = {};\n    if(typeof Connection!==\"undefined\"){\n        states[Connection.UNKNOWN]  = 'Unknown connection';\n        states[Connection.ETHERNET] = 'Ethernet connection';\n        states[Connection.WIFI]     = 'WiFi connection';\n        states[Connection.CELL_2G]  = 'Cell 2G connection';\n        states[Connection.CELL_3G]  = 'Cell 3G connection';\n        states[Connection.CELL_4G]  = 'Cell 4G connection';\n        states[Connection.CELL]     = 'Cell generic connection';\n        states[Connection.NONE]     = 'No network connection';\n\n        alert('Connection type: ' + states[networkState]);\n<\/code><\/pre>\n<p>This returns the connection as expected. Currently <code>WiFi connection<\/code><\/p>\n<p><strong>config.xml<\/strong><\/p>\n<pre><code>\n\n    \n\n<\/code><\/pre>\n<p><strong>AndriodManiest.xml<\/strong><\/p>\n<pre><code>\n\n\n<\/code><\/pre>\n<p><strong>JS used to call said http request<\/strong><\/p>\n<pre><code>            $.ajax({\n                url: 'http:\/\/stage.sexdiaries.co.uk\/app\/users\/login',\n                type: 'post',\n                data: {\n                    'uname': values.uname,\n                    'pword': values.pword\n                },\n                crossDomain: true,\n                error: function(data){\n                    c(data.status);\n                },\n                success: function(data){\n                    c('success: '+data);\n                    data = JSON.parse(data);\n                    if(data.privateKey){\n                        $.jStorage.set('uid',data.ud.uid); \/\/store user ID in the localStorage to persist\n                        sessionStorage.setItem('privateKey',data.privateKey); \/\/store privateKey in session so it disapears when the user closers the tab\n                        Backbone.history.loadUrl('');\n                    }\n                }\n            });\n<\/code><\/pre>\n<p>So I know that the connection is active. Do I really have a connection? Am I crazy? How can I reach this http request?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3559","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3559"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3559\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}