Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile pageloadfailed event

jQuery Mobile pageloadfailed event

jQuery Mobile Events jQuery Mobile Events

Example

Pop up a message when a page fails to load:

$(document).on("pageloadfailed",function(){

  alert("Sorry, the requested page does not exist.");

});

Try it »


Definition and Usage

Deprecated after version 1.4.0, use pagecontainerloadfailed as a replacement.

The pageloadfailed event is triggered when a page fails to load.

Related events:

Note: When an external page is loaded into the DOM, two types of events are definitely triggered: the pagebeforeload event before loading, and pageload (load succeeded) or pageloadfailed (load failed) after loading.


Syntax

$("document").on("pageloadfailed",function(event,data){...})

Parameters Description
function(event,data) Required. Specifies the function to execute after the pageloadfailed event is triggered.

This function contains the following two parameters:

Event Object - Includes any jQuery event properties (event.target, event.type, etc.). For more information, refer to the jQuery event reference manual

Data object - Contains the following types:

  • url (string) - The absolute or relative address passed to $.mobile.loadPage() via callback
  • absUrl (string) - Contains an absolute reference to the URL
  • dataUrl (string) - Contains the browser's URL location
  • deferred (object) - Contains resolve() or reject()
  • options (object) - Contains options sent to $.mobile.loadPage()
  • xhr (object) - Contains the XMLHttpRequest object (sent as the third parameter to the $.ajax() success callback)
  • errorThrown - (null, string, object) - When an HTTP error occurs, errorThrown receives HTTP status information, such as "Not Found" or "Internal Server Error" (passed as the third parameter to the $.ajax() error callback)
  • |

    More examples

    Related events demonstration.
    pageload and pageloadfailed event demo.

    Event Object
    Use the event.type property to return the type of event that was triggered.

    Data object
    Use data.url to return the URL of the page that failed to load.

    Data object
    Use data.errorThrown to return error information when a page is not found.


    jQuery Mobile Events jQuery Mobile Events