2

I am building iOS app in Phonegap and trying to do an ajax POST call to remote server. Server gets the call. It responds fine, but the server doesn't seem to get any of the POST data.

Ajax call is as follows :

 var formData = $(this).serialize();
 $.ajax({
        type:'post',
        url:'https://www.mySite.com/ajax/test',
        data: formData,
        dataType: "json",
        crossDomain:true,
        async: true,
        success: function (result) {
            alert(result.success)
        },
        error: function (request,error) {
        alert('error');
    }
});

On the server (for testing purposes), I'm just bringing it back

$json = array('success' => 'true'.serialize($_POST));

I print the $_POST variable on the server. Whenever the iPhone gets the callback, all the POST data is missing. The variable formData definitely has the information. I'm confused whether it actually sends it or the server strips it away.

Any help is greatly appreciated.

  • not rly sure why its not working, i'm using it almost the same way and works, I'm just not using those dataType,crossDomain and async proprieties – Enoque Duarte Jun 07 '13 at 23:04
  • This a known problem on iOS6. Look at a solution here: http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results – Vlad Stirbu Jun 08 '13 at 18:20
  • I thought this would work, still having problems even setting everything to not cache and even going the extra step and adding a random number to the url. The GET parameters appear fine, just no POST data. I even created a different PHP file just in case –  Jun 09 '13 at 16:47
  • Did you ever solve this issue? I'm experiencing very similar behavior in my phone gap app when using `phonegap serve` – Thought Space Designs Apr 21 '15 at 18:32

0 Answers0