我正在使用 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/