YouTip LogoYouTip

Event Pageloadfailed

# jQuery Mobile pageloadfailed Event [![Image 4: jQuery Mobile Events](#) jQuery Mobile Events](#) ## Example Alert a message when the page fails to load: ```javascript $(document).on("pageloadfailed",function(){ alert("Sorry, the requested page does not exist."); }); [Try it Β»](#) * * * ## Definition and Usage Deprecated since version 1.4.0, use (#) instead. The pageloadfailed event is triggered when a page fails to load. **Related Events:** - Event triggered before any loading starts - Event 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 either the pageload (on success) or pageloadfailed (on failure) event after loading. * * * ## Syntax ```javascript $("document").on("pageloadfailed",function(event,data){...}) | Parameter | Description | | --- | --- | | function(event,data) | Required. Specifies the function to run after the pageloadfailed event is triggered. This function has the following two parameters:
**Event Object** - Includes any jQuery event properties (event.target, event.type, etc.). For more information, see the (#).
**Data Object** - Contains the following types:
* **url** (string) - The absolute or relative URL passed to $.mobile.loadPage() via the callback.
* **absUrl** (string) - Contains the absolute reference of 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 parameter to the $.ajax() success callback).
* **errorThrown** - (null, string, object) - When an HTTP error occurs, errorThrown receives the HTTP status message, such as "Not Found" or "Internal Server Error" (sent as the third parameter to the $.ajax() error callback). | * * * ![Image 5: Example](#) ## More Examples [Demonstration of related events.](#) Demonstration of the pageload and pageloadfailed events. (#) Use the event.type property to return the type of event triggered. (#) Use data.url to return the URL of the page that failed to load. (#) Use data.errorThrown to return the error message when the page is not found. * * jQuery Mobile Events](#)
← Event PageshowEvent Pageload β†’