Chr*_*ert 5 jquery post zend-framework jquery-ui
我刚刚从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*
}
}
});
Run Code Online (Sandbox Code Playgroud)
一切都很好.现在新代码:
$( "#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*
});
}
});
Run Code Online (Sandbox Code Playgroud)
所以我需要将这些数据发布format=html到我的服务器,但是对于新版本,发送到服务器的发布变量是空的.没有任何内容发送到服务器.另外,如果我想在我php script的数组中获取POST变量是空的.我正在使用ZENDbtw.我需要通过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*
});
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4164 次 |
| 最近记录: |