Example
Alert some text when the page load request fails:
$(document).on("pageloadfailed",function(){
alert("Sorry,
requested page does not exist.");
});
Try it Yourself »
Definition and Usage
The pageloadfailed event was deprecated in jQuery version 1.4.0. Use the pagecontainerloadfailed event instead.
The pageloadfailed event is triggered if the page load request fails.
Related events:
- pagebeforeload - triggered before any load request is made
- pageload - triggered after the page has been successfully loaded and inserted into the DOM.
Note: These events are used for external pages - Whenever an external page is loaded into the DOM, 2 events are fired. The first is pagebeforeload. The 2nd event will either be pageload or pageloadfailed.
Syntax
$("document").on("pageloadfailed",function(event,data){...})
Parameter | Description |
---|---|
function(event,data) | Required. Specifies the function to run when the pageloadfailed event occurs.
The function has two optional parameters: The event object - which can contain any jQuery event properties (e.g. event.target, event.type, etc.) See jQuery Events Reference for more information The data object - contains the following:
|
Try it Yourself - Examples
A demonstration of
related events
A demonstration of pageload and pageloadfailed.
The event object
Using the event.type property to return the triggered event type.
The data object
Using data.url
to return the URL of the unsuccessful page load.
The data object
Using data.errorThrown to return some text when a page is not found.