Note that there are some explanatory texts on larger screens.

plurals
  1. POPhonegap upgrade breaks Ajax call
    primarykey
    data
    text
    <p>I recently updated the version of PhoneGap I was using from 0.9.5 to Cordova-1.7.0. Since the upgrade I am no longer able to post data to my server through an Ajax call from an android device although it works fine in a browser. </p> <p>The jqXHR status code that is being returned is 0 - indicating that there is a problem with the net workup but I am able to retrieve data from the server without any issues.</p> <p>Has something changed in the way that data is posted to the server between 0.9.5 and 1.7.0?</p> <p>My ajax call is below:</p> <pre><code> $.ajax({ type: "POST", url: "https://"+serverUrl + "process.php", data: {data:passData, key:appKey}, crossDomain: true, cache: false, dataType: "text", timeout: 5000, success: onSuccess, error: onError }); function onError(jqXHR, exception) { if (jqXHR.status === 0) { alert('Not connect.\n Verify Network.'); } else if (jqXHR.status == 404) { alert('Requested page not found. [404]'); } else if (jqXHR.status == 500) { alert('Internal Server Error [500].'); } else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); } else if (exception === 'timeout') { alert('Time out error.'); } else if (exception === 'abort') { alert('Ajax request aborted.'); } else { alert('Uncaught Error.\n' + jqXHR.responseText); } showAlert("Failed to transmit, saved for re-transmital.", "Alert", 1); } function onSuccess(data){ alert('successfully transmitted'); } </code></pre> <p><strong>UPDATE</strong> Added "async: false" to my call and it worked. See updated code below:</p> <pre><code>$.ajax({ type: "POST", url: "https://"+serverUrl + "process.php", data: {data:passData, key:appKey}, crossDomain: true, cache: false, async: false, dataType: "text", timeout: 5000, success: onSuccess, error: onError }); </code></pre>
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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