【问题标题】:jQuery mobile: How to invoke this (default) error loading page message?jQuery mobile:如何调用此(默认)错误加载页面消息?
【发布时间】:2011-11-25 09:43:05
【问题描述】:

我正在构建 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();
}

【问题讨论】:

    标签: javascript jquery ajax jquery-mobile


    【解决方案1】:
    //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();
      });
    

    【讨论】:

    • 如果您确保您的 div 与标准错误 div 具有相同的类,则 css 只需要 display:block
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多