jQuery Mobile pageloadfailed event
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:
- pagebeforeload - An event triggered before any loading
- pageload - Triggered after a page is successfully loaded and inserted into the DOM.
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: |
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