Handle page load failed event
Description
The following code shows how to handle page load failed event.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type="text/javascript"
src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.css">
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!--from w w w . j a va2s. co m-->
$(document).on("pageloadfailed", function(event, data){
event.preventDefault();
var errMessage = data.xhr.status + " " + data.xhr.statusText;
setTimeout(function(){
$.mobile.loading('hide');
$.mobile.loading('show', {theme:"e", text:errMessage, textonly:true, textVisible: true});
},50);
setTimeout(function(){$.mobile.loading('hide')}, 2000);
data.deferred.reject(data.absUrl, data.options);
});
});//]]>
</script>
</head>
<body>
<div data-role="page" id="page1">
<div data-role="header">
<h1>Header</h1>
</div>
<div data-role="content">
<a href="asdf.php" data-role="button">Go to Error Page</a>
</div>
<div data-role="footer" data-position="fixed">
<h1>Footer</h1>
</div>
</div>
</body>
</html>