jQuery Mobile pagecontainerloadfailedEvent

jQuery Mobile 事件jQuery Mobile Events

Examples

Display a text message after the page is successfully loaded and inserted into the DOM:

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

Try it Yourself »

Definition and Usage

The pagecontainerload event is triggered after the page is successfully loaded and inserted into the DOM.

Related events:

  • pagecontainerbeforeload - Triggered before the load request
  • pagecontainerload- Triggered after the page is successfully loaded and inserted into the DOM

Note:This event is used for external pages - after the page is loaded and inserted into the DOM, 2 events will be triggered. The first event is pagecontainerbeforeload, and the second event may be pagecontainerload or pagecontainerloadfailed.


Syntax

$("document").on("pagecontainerloadfailed",function(event,data){...})
Parameter Description
function(event,data) Required. Specifies the function to execute after the event is triggered.

This function has two optional parameters:

event object- Contains jQuery event properties (e.g., event.target, event.type, etc.). SeejQuery Event Reference Manualfor more information.

data object- Contains the following:

  • url(string) - The absolute or relative URL address of the page (sent to $.mobile.loadPage())
  • absUrl(string) - The absolute path of the URL
  • dataUrl(string) - The corresponding URL address in the browser
  • deferred(object) - Contains resolve() or reject()
  • options(object) - Options sent to $.mobile.loadPage()
Note:In the event object, you can manually handle the request by calling event.preventDefault(). The deferred object in the data object contains resolve() or reject() methods.
实例

More Examples

Related Event Demos
Demonstrations of the pagecontainerload and pagecontainerloadfailed events.

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 address of the external page.

data object
Use data.errorThrown to return some information when the page does not exist.

Other Extensions