1

如果我想显示没有连接的错误消息,这是以前的方式:

$("#tabs").tabs({
        ajaxOptions:{
            error: function(xhr,status,index,anchor){
                $(anchor.hash).html('Could not connect to server')
            }
        }
});

beforeLoad但是现在根据 API 文档,不推荐使用 ajaxOptions 。应该如何达到同样的效果?假设我有一个连接到位于服务器上的 php 文件的选项卡,当没有连接时它显示

“无法连接到服务器”。

4

2 回答 2

1

实际上在jQueryUI 选项卡示例页面上有一个示例。像这样的东西应该工作:

$('#tabs').tabs({
    beforeLoad: function (event, ui) {
        ui.jqXHR.error(function () {
            ui.panel.html(
                "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                "If this wouldn't be a demo.");
        });
    }
});

示例:http: //jsfiddle.net/WP29E/146/

于 2013-10-23T18:49:29.903 回答
0

看这篇文章How to change `cache` and `ajaxOptions` when upgrade to jQuery UI 1.10?

将成功和事件处理程序添加到您的 ui.jqXHR 对象。

于 2013-10-23T18:42:55.540 回答