jQuery Mobile Framework

Navigation Search

Question:

I'm trying to use the application cache but it's not working.

Answer:

The issue here is not actually jQuery Mobile but the fact that some browsers return a status of zero. This causes the internal error handlers to be triggered in jQuery's AJAX function.

There is a simple workaround for this:


$.ajaxPrefilter( function(options, originalOptions, jqXHR) {
  if ( applicationCache &&
    applicationCache.status != applicationCache.UNCACHED &&
    applicationCache.status != applicationCache.OBSOLETE ) {
     // the important bit
	options.isLocal = true;
  }
});

One important note on this workaround is that this sets is local to true for all AJAX requests weather or not they are in the manifest. This works currently because is local is only checked As long as the cache is valid and the status is 0 so it doesn't affect uncached results. This may change in the future breaking applications using this workaround.

All Questions & Answers