jQuery ajaxOptions -error 有效,为什么不成功?

标签 jquery jquery-ui jquery-ui-tabs

我正在使用 jQuery UI 选项卡,并且正在使用示例代码:

$(function() {
    $("#tabs").tabs({
        ajaxOptions: {
            error: function(xhr, status, index, anchor) {
                $(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible. If this wouldn't be a demo.");
            }
        }
    });
});

这里的问题是我想捕获 AJAX 成功以获取 JSON 对象以将数据注入(inject) DIV...

但这不起作用

$(function() {
        $("#tabs").tabs({
            ajaxOptions: {
                success: function(xhr, status, index, anchor) {
                    alert('hello world');
                },
                error: function(xhr, status, index, anchor) {
                    $(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible. If this wouldn't be a demo.");
                }
            }
        });
    });

想法?

谢谢

最佳答案

如果您复制并粘贴,则会在成功函数之后、“错误”之前缺少一个逗号。

关于jQuery ajaxOptions -error 有效,为什么不成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3971911/

相关文章:

javascript - 单击时,将类添加到行中的第一个 <td> 和表中相应的 <th>

jquery - 在 bootstrap carousel 中使用图像而不是幻灯片的背景

javascript - 更改 jQuery UI 小部件中的深层选项

javascript - 如何实现 float 可拖动面板

jquery - 使用 jquery 打印特定的 div

IE中通过ajax加载的部分 View 中jquery未定义

javascript - TinyMCE 更改文本区域背景色

javascript - 使用 jQuery 更改所有图像的图像源

jQuery UI 选项卡 - 深度链接到选项卡内容

jquery - 选定的选项卡 ID?