使用jQuery标签ajaxoptions发布数据 [英] Posting data with jQuery tabs ajaxoptions
问题描述
我用下面的code初始化我的标签
I'm using the following code to initialize my tabs
$('#tabs').tabs({
fx: {
opacity: 'toggle',
duration: 'fast'
},
select: function () {
$(this).tabs("option", {
ajaxOptions: { data: vehicleJson }
});
},
ajaxOptions: {
type: 'post',
success: function(){
alert('onSuccess');
},
error: function(){
alert('onFail');
}
},
spinner: ''
}
在我的控制器我有:
[HttpPost]
public PartialViewResult Intervals(string vehicleJson)
{
return PartialView("_Intervals");
}
如果我删除[HttpPost] ATTRIB,似乎工作正常,但它不是一个'后',我需要。基本上我试图传递一个JSON对象到一个职位。我究竟做错了什么?这里是最初的HTML我的标签
If I remove the [HttpPost] attrib, it seems to work ok, except it is not a 'post' which I need. Basically I'm trying to pass a json object up to a post. What am I doing wrong? Here is the initial HTML for my tabs
<ul id="ul-tabs">
<li><a href="/maintenance/Tabs/Intervals" title="Intervals">Intervals</a></li>
<li><a href="/maintenance/Tabs/Lifetime" title="Lifetime Services">Lifetime Services</a></li>
<li><a href="/maintenance/Tabs/Locator" title="Locator">Locator</a></li>
<li><a href="/maintenance/Tabs/Procedures" title="Procedures">Procedures</a></li>
<li><a href="/maintenance/Tabs/Specifications" title="Specifications">Specifications</a></li>
<li><a href="/maintenance/Tabs/Reset" title="Reset">Reset</a></li>
</ul>
我如何正确地强制链接做一个职位,而不是得到什么?我想用在服务器端的JavaScript数据。
How do I correctly force the links to do a post rather than a get? I want to use the javascript data on the server side.
对于提示或建议,结果谢谢
干杯,结果
〜CK在圣地亚哥
Thanks for a tips or advice,
Cheers,
~ck in San Diego
推荐答案
您要覆盖 ajaxOptions
上标签的选择的
这行:
$(this).tabs("option", { ajaxOptions: {data: vehicleJson}});
将覆盖previously设置选项,并导致标签使用jQuery AJAX默认值(TYPE =GET)。
Will overwrite your previously set options and cause tabs to use jQuery ajax defaults (type="GET").
您可以修复它是这样的:
var tabAjaxOpts = {
type:'post',
success:function(){alert('onSuccess');},
error:function(){alert('onFail');}
};
$('#tabs').tabs({
fx: {
opacity: 'toggle',
duration: 'fast'
},
select: function () {
tabAjaxOpts.data = vehicleJson;
$(this).tabs("option", { ajaxOptions: tabAjaxOpts});
},
ajaxOptions: tabAjaxOpts
};
这篇关于使用jQuery标签ajaxoptions发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!