jQuery pageloadfailed Event

## jQ Mobile Tutorial

jQ Mobile HOME jQ Mobile Intro jQ Mobile Install jQ Mobile Pages jQ Mobile Transitions jQ Mobile Buttons jQ Mobile Icons jQ Mobile Toolbars jQ Mobile Navbars jQ Mobile Collapsibles jQ Mobile Grids

## jQ Mobile Lists

jQ Mobile List Views jQ Mobile List Content

## jQ Mobile Forms

jQ Mobile Form Basic jQ Mobile Form Inputs jQ Mobile Form Select jQ Mobile Form Sliders

## jQ Mobile Themes

jQ Mobile Themes

## jQ Mobile Events

jQ Mobile Events jQ Mobile Touch jQ Mobile Scroll jQ Mobile Orientation jQ Mobile Page Events

## Examples

jQ Mobile Examples

## References

jQ Data Attributes jQ Events jQ Icons

# jQuery pageloadfailed Event

jQuery Mobile Events

## 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 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:

- url (string) - contains the absolute or relative URL of the page (that was sent to $.mobile.loadPage())
- absUrl (string) - contains the absolute reference of the URL
- dataUrl (string) - contains the URL of the browser's location
- deferred (object) - contains resolve() or reject()
- options (object) - contains the options that were sent to $.mobile.loadPage()
- xhr (object) - contains the XMLHttpRequest object (Sent as the 3rd argument to $.ajax() success callback)
- textStatus (string or null) - contains the status of the request ("success" or "null") (Sent as the 2nd argument to $.ajax() error callback)
- errorThrown - (null, string, object) - When an HTTP error occurs, errorThrown receives the text of the HTTP status, such as "Not Found" or "Internal Server Error (sent as the 3rd argument to $.ajax() error callback)

## 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.

jQuery Mobile Events

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE