jQuery mobile:如何调用此(默认)错误加载页面消息? [英] jQuery mobile: How to invoke this (default) error loading page message?
本文介绍了jQuery mobile:如何调用此(默认)错误加载页面消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在构建 RESTful 移动应用程序,我喜欢找不到资源时的默认行为.jQuery Mobile 显示了这一点:
I am building RESTful mobile app and I like the default behaviour when resource is not found. jQuery Mobile shows this:
但是,当我在 onError 中执行自定义 AJAX 时(因为找不到资源),我想显示花哨的消息(但是,我的代码中没有任何反应,默认行为被忽略):
However, when I do my custom AJAX in onError (because resource is not found) I'd like to show fancy message (however, nothing happens in my code, default behavior is ignored):
$("#some-place").bind("pageshow", function() {
$.ajax({
type: "POST",
url: "some-place/places.json",
cache: false,
dataType: "json",
success: onSuccessInitPlaces,
error: onErrorInitPlaces
});
return false;
});
function onSuccessInitPlaces(data, status) {
// do stuff, not important atm
}
function onErrorInitPlaces(data, status) {
// pseudocode I'd like to invoke for real
// should show attached picture
invokeFancyErrorLoadingPage();
}
推荐答案
//show error message
$( "<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h1>YOUR MESSAGE</h1></div>" )
.css({ "display": "block", "opacity": 0.96, "top": $(window).scrollTop() + 100 })
.appendTo( $.mobile.pageContainer )
.delay( 800 )
.fadeOut( 400, function() {
$( this ).remove();
});
这篇关于jQuery mobile:如何调用此(默认)错误加载页面消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文