Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap Cross-domain AJAX POST Request not working on Android
    primarykey
    data
    text
    <p>Cross-domain AJAX POST request works perfectly fine on web browsers including browsers on mobile phones, but doesn't work for native applications built using <code>Phonegap</code></p> <p>I have created a login form that users have to enter their login credentials, then they are verified by the server that is hosted on heroku and returns json <code>{"success":true}</code> if valid credentials are entered.</p> <p><strong>My Ajax script:</strong></p> <pre><code>$.ajax({ type: "POST", url: "http://domain.com/public/auth/app-login", contentType: "application/x-www-form-urlencoded; charset=utf-8", dataType: "json", data: {identity: &lt;username from form&gt;, password: &lt;password from form&gt;}, crossDomain: true, cache: false, success: function(data) { obj = JSON.parse(data); if (obj &amp;&amp; obj.success === true) { window.location.href = 'home.html'; } }, error: function(e) { alert('Error: ' + e.message); } }); </code></pre> <p><strong>Steps taken to resolve this issue:</strong></p> <ul> <li><a href="http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html">Domain whitelisting</a> - config.xml</li> </ul> <p><code> &lt;access origin="http://domain.com/public/auth/app-login" /&gt; </code></p> <p><code> &lt;access origin="*" /&gt; </code></p> <ul> <li>Telling jQuery to allow cross-domain</li> </ul> <p><code> $.support.cors = true; </code> OR <code> jQuery.support.cors = true; </code></p> <ul> <li>Disable caching <code>cache: false</code></li> </ul> <p>Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload