jQuery mobile:如何调用此(默认)错误加载页面消息?

2024-02-03

我正在构建 RESTful 移动应用程序,我喜欢找不到资源时的默认行为。 jQuery Mobile 显示了这一点:

但是,当我在 onError 中执行自定义 AJAX 时(因为未找到资源),我想显示奇特的消息(但是,我的代码中没有任何反应,默认行为被忽略):

$("#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();
  });
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jQuery mobile:如何调用此(默认)错误加载页面消息? 的相关文章

随机推荐