Skip to main content

jquery mobile “error loading page” workaround

By Sam Deering

JavaScript

Share:

Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

If your seeing a quick error message popup on the screen when redirecting the page to another (or you might be forcing a reload).

Image

Instead of using this:

window.location.href = "/";

Use this:

$.mobile.changePage('/', { reloadPage: true, transition: "none"} );

or if that doesn’t work try this:

$.mobile.changePage('./', { reloadPage: true });

That should fix it. If it don’t then try this, overriding the default settings for the ajax loading error (not recommended but will hack fix it).

$.mobile.pageLoadErrorMessage = "";

Docs: http://jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html

$(document).bind("mobileinit", function(){
  $.mobile.foo = bar;
});

If that still don’t fix it, maybe your using the file protocol?

ref: http://doeswhat.com/2011/03/08/jquery-mobile-error-loading-page/

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

New books out now!

Get practical advice to start your career in programming!


Master complex transitions, transformations and animations in CSS!