Latest web development tutorials

jQuery Mobile pageloadfailed event

jQuery Mobile Events jQuery Mobile Events

Examples

Failed pop-up message when the page loads:

$(document).on("pageloadfailed",function(){
alert("抱歉,请求的页面不存在。");
});

try it"

Definition and Usage

After the 1.4.0 version is obsolete, use pagecontainerloadfailed instead.

pageloadfailed event is triggered when the page failed to load.

Related events:

  • pagebeforeload - prior to any loading event triggered
  • pageLoad - triggered after the page has successfully loaded and inserted into the DOM.

Note: The external page is loaded into the DOM, the event will certainly trigger type 2. Before loading the pagebeforeload event, and after loading pageload (loaded successfully) or pageloadfailed (failed to load).


grammar

$ ( "Document"). On ( "pageloadfailed", function (event, data) {...})

参数 描述
function(event,data) 必须。指定 pageloadfailed 事件触发后执行的函数。

该函数含有以下两个参数:

事件对象 - 包括任何jQuery事件属性 ( event.target, event.type 等) 。更多信息请查阅 jQuery 事件参考手册

数据对象 - 包含以下类型:

  • url (string) - 通过回调传到$.mobile.loadPage()的绝对或者相对地址
  • absUrl (string) - 包含URL的绝对引用
  • dataUrl (string) - 包含浏览器的URL 位置
  • deferred (object) - 包含 resolve() 或 reject()
  • options (object) - 包含可选项发送到 $.mobile.loadPage()
  • xhr (object) - 包含 XMLHttpRequest 对象 (作为第三个参数发送到 $.ajax() 成功回调)
  • errorThrown - (null, string, object) - 在 HTTP 发送错误时,errorThrown 接收HTTP状态信息,如 "Not Found(没有找到页面)" 或 "Internal Server Error(服务器内部错误)" (作为第三个参数传给 $.ajax() 错误回调)


Examples

More examples

Related events demonstrate.
pageload and presentation pageloadfailed events.

Event objects
Use event.type property to return the type of trigger event.

Data Objects
Use data.url return URL is not successfully loaded the page.

Data Objects
When the page is not found, use data.errorThrown returns an error message.


jQuery Mobile Events jQuery Mobile Events