jQuery Mobile pageloadfailedEvent

jQuery Mobile 事件jQuery Mobile Events

Examples

Pop up a message when page loading fails:

$(document).on("pageloadfailed",function(){
alert("Sorry, the requested page does not exist.");
});

Try it Yourself »

Definition and Usage

Deprecated since version 1.4.0, usepagecontainerloadfailedinstead.

The pageloadfailed event is triggered when page loading fails.

Related events:

  • pagebeforeload- Event triggered before any loading
  • pageload- Triggered after the page is successfully loaded and inserted into the DOM.

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


Syntax

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

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

The function contains the following two parameters:

Event object- Includes any jQuery event properties (event.target, event.type, etc.). For more information, seejQuery Event Reference Manual

Data object- Contains the following types:

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


实例

More Examples

Related events demonstration.
Demonstration of the pageload and pageloadfailed events.

Event object
Use the event.type property to return the type of the triggered event.

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

Data object
When the page is not found, use data.errorThrown to return the error message.


jQuery Mobile 事件jQuery Mobile Events

Other extensions