Android does not fire AJAX requests because they are cached (on jQuery mobile)


Before a few days I posted about the pain I had with jQuery mobile, Phonegap and Android. One of the most confusing things was that Android did not send Ajax requests all the time I wanted it. This left my app back in nasty states. I was already assuming that the Android “browser” does some caching, but my investigations were without success.

Then I had a nice conversation on the Strut2 mailinglist on JSON security. To reason my arguments I checked out the .ajax docs from jQuery again and then… there is actually a “cache” property. And it is set to true by default.

This causes trouble with Android, but not on the iPhone. If you set this property to false, Android will send out all the Ajax requests you need.

Your request should look like:

       url: "yoururl.html",
          context: document.body,
          cache : false,
          data: {
               username :  $('#username').val(),
               password :  $('#password').val(),
          success: function ( data ) {
              // do something

Try that, when Android does not fire your AJAX requests.

Tags: #Android #jQuery mobile #mobile #phonegap