从jquery ajax调用控制器方法 [英] call controller method from jquery ajax
本文介绍了从jquery ajax调用控制器方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi
i am developing web application in visual studio 2012 , ultimate..and i use ajax -post in jquery to pass values to controller.
how to call method in HomeController.cs from jquery ajax - json..
pls give example code to call
推荐答案
.ajax({
async:false,
cache:false,
键入:POST,
url:@(Url.Action(YourAction,YourController)),
data:{id:ui .item.Id},
成功:功能(数据){
}
});
回复(客户);
}
.ajax({
async: false,
cache: false,
type: "POST",
url: "@(Url.Action("YourAction", "YourController"))",
data: { "id": ui.item.Id },
success: function (data) {
}
});
response(customer);
}
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult ActionName(int id)
{
....Your Code....
return Json(model);
}
下面是进行ajax -post调用的示例代码
Below is sample code to make ajax –post call
//assign the value which you want to post
var value;
这篇关于从jquery ajax调用控制器方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文