JavaScript
Article
By Sam Deering

jquery mobile “error loading page” workaround

By Sam Deering
Help us help you! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

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:

--ADVERTISEMENT--

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/

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?