gpt4 book ai didi

jquery - 发布数据 JQuery UI 选项卡 1.10

转载 作者:行者123 更新时间:2023-12-03 23:03:43 27 4
gpt4 key购买 nike

我刚刚从JQ UI 1.8.23切换到1.10。对于这个版本,ajaxOptions已被弃用,现在ui.ajaxSettings已被弃用而是使用。

这就是我的代码的样子:

$( "#tabs" ).tabs({
ajaxOptions: {
type : 'POST',
data : 'format=html',
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. " );
},
success: function() {
*Something in here*
}
}
});

一切都很好。现在新代码:

$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.ajaxSettings.type = 'POST';
ui.ajaxSettings.data = 'format=html';
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." );
});
ui.jqXHR.success(function(){
*something in here*
});
}
});

因此,我需要将此数据 format=html 发布到我的服务器,但在新版本中,发送到服务器的发布变量为空。没有任何内容发送到服务器。另外,如果我想在我的 php 脚本 中获取 POST 变量,则数组为空。顺便说一句,我正在使用 ZEND 。我需要通过 POST 发送它 - 没有办法解决它。

感谢您的帮助

最佳答案

如果您查看 jQuery.ajax 的源代码,在第 486 行,您将看到它将数据添加到 url 中。然后在第 532 行,它调用 beforeSend 方法,该方法触发 jQuery UI 选项卡中的 beforeLoad 事件。

所以你需要做的就是修改 url 而不是数据:

$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.ajaxSettings.type = 'POST';
ui.ajaxSettings.url += ( /\?/.test( ui.ajaxSettings.url ) ? "&" : "?" ) + 'format=html';
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." );
});
ui.jqXHR.success(function(){
*something in here*
});
}
});

关于jquery - 发布数据 JQuery UI 选项卡 1.10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14480797/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com