pageloadfailed


pageloadfailed eventversion added: 1.0

Description: Triggered if the page load request failed.

  • jQuery( ".selector" ).on( "pageloadfailed", function( event ) { ... } )

By default, after dispatching this event, the framework will display a page failed message and call reject() on the deferred object contained within the event's data object. Callbacks can prevent this default behavior from executing by calling preventDefault() on the event.

The data object, passed as the 2nd arg to the callback function contains the following properties:

  • url (string)
    • The absolute or relative URL that was passed into $.mobile.loadPage() by the caller.
  • absUrl (string)
    • The absolute version of the url. If url was relative, it is resolved against the url used to load the current active page.
  • dataUrl (string)
    • The filtered version of absUrl to be used when identifying the page and updating the browser location when the page is made active.
  • deferred (object)
    • Callbacks that call preventDefault() on the event, *MUST* call resolve() or reject() on this object so that changePage() requests resume processing. Deferred object observers expect the deferred object to be resolved like this:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      $( document ).on( "pageloadfailed", function( event, data ) {
      // Let the framework know we're going to handle things.
      event.preventDefault();
      // ... attempt to load some other page ...
      // at some point, either in this callback, or through
      // some other async means, call resolve, passing in
      // the following args, plus a jQuery collection object
      // containing the DOM element for the page.
      data.deferred.resolve( data.absUrl, data.options, page );
      });

      or rejected like this:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      $( document ).on( "pageloadfailed", function( event, data ) {
      // Let the framework know we're going to handle things.
      event.preventDefault();
      // ... attempt to load some other page ...
      // at some point, if the load fails, either in this
      // callback, or through some other async means, call
      // reject like this:
      data.deferred.reject( data.absUrl, data.options );
      });
  • options (object)
    • This object contains the options that were passed into $.mobile.loadPage().
  • xhr (object)
    • The jQuery XMLHttpRequest object used when attempting to load the page. This is what gets passed as the first argument to the framework's $.ajax() error callback.
  • textStatus (null or string)
    • According to the jQuery Core documentation, possible values for this property, aside from null, are "timeout", "error", "abort", and "parsererror". This is what gets passed as the 2nd argument to the framework's $.ajax() error callback.
  • errorThrown (null, string, object)
    • According to the jQuery Core documentation, this property may be an exception object if one occurred, or if an HTTP error occurred this will be set to the textual portion of the HTTP status. This is what gets passed as the 3rd argument to the framework's $.ajax() error callback.