如何使用java脚本调用action方法? [英] How to call action method using java script?
本文介绍了如何使用java脚本调用action方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户在文本框中输入时,我希望通过java脚本调用Action方法。
我的搜索操作方法是
I want call a Action Method through java script when user typing in textbox.
my Search Action Method is
[HttpPost]
[MultiButton(MatchFormKey = "action", MatchFormValue = "Search")]
public ActionResult Search(string SearchKey, FormCollection collection)
{
string key = collection["txtSearch"];
ProjectUtility OProjectUtility = new ProjectUtility();
IEnumerable<Project> obj = OProjectUtility.SearchByKey(key);
return View(obj);
}
在ProjectManager控制器下。
如何使用java脚本调用它?
Under "ProjectManager" Controller.
How i can call it using java script?
推荐答案
你可以使用jQuery ajax如下(样本):
You can use jQuery ajax is as below (sample):
function AddToCart(id)
{
.ajax({
url:/ Portal / GetPurchasedPackages ,
dataType:'json',
data:{id:id},
success:function(){
alert('Added');
}
});
}
.ajax({ url: "/Portal/GetPurchasedPackages", dataType: 'json', data: { id: id }, success: function(){ alert('Added'); } }); }
检查更多: jQuery.ajax()
我希望这会对你有所帮助。
Check for More:jQuery.ajax()
I hope this will help to you.
这是一个解决方案适合您的问题
http://ericdotnet.wordpress.com/2009/04/09/jquery-search-box-and-aspnet-mvc/ [ ^ ]
Here's a solution which suits your problem
http://ericdotnet.wordpress.com/2009/04/09/jquery-search-box-and-aspnet-mvc/[^]
这篇关于如何使用java脚本调用action方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文