[英]How to call a action method from Jquery?
I have a action method that returns stringbuilder object which has a html table as output.我有一个操作方法,它返回 stringbuilder 对象,该对象有一个 html 表作为输出。 i will this output to be fired from a tab click(having n number of tabs, on tab click name of tab is passed to a jquery function).
我将从选项卡单击中触发此输出(具有 n 个选项卡,在选项卡上单击选项卡的名称被传递给 jquery 函数)。 please find below code
请找到下面的代码
<li onclick="BindData1(this.id);" id="tab1">
<a href="#tabs-2">Text</a></li>
code:代码:
function BindData1(TechName) {
$.ajax({
url: '@Url.Action("ActionMethod", "Controller")',
data: {
id: TechName
}
}).done(function() {
if (data != undefined) {
//bind to page
} else
alert('error');
});
}
function BindData1(TechName) { $.ajax({ type: "POST", url: '/ControllerName/ActionMethodName', data: { 'techname': "TechName" }, success: function (data) { if(data.success) { $("#contentwrapper").html(data); } else { alert('error'); } }), }); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.