如何使用$.ajax(…)传递FormCollection对象
我正在使用MVC应用程序,在控制器中有两种操作方法:如何使用$.ajax(…)传递FormCollection对象,ajax,asp.net-mvc,asp.net-mvc-4,Ajax,Asp.net Mvc,Asp.net Mvc 4,我正在使用MVC应用程序,在控制器中有两种操作方法: [MultipleButton(Name = "action", Argument = "Save")] public ActionResult SaveBasicInformation(FormCollection collection) {.....} [MultipleButton(Name = "action", Argument = "Submit")] public ActionResult SubmitRequest(Form
[MultipleButton(Name = "action", Argument = "Save")]
public ActionResult SaveBasicInformation(FormCollection collection)
{.....}
[MultipleButton(Name = "action", Argument = "Submit")]
public ActionResult SubmitRequest(FormCollection collection)
{....}
以上代码在没有ajax请求的情况下运行良好。现在我的问题是如何在$.ajax中传递FormCollection。。对于特定的控制器方法
var input = $(':input');
$.ajax({
url: '@Url.Action("SaveBasicInformation", "Home")',
type: 'POST',
cache: false,
data: input,
success: function (data) {
alert("Success");
},
error: function (result) {
alert("Error");
alert(result.responseText);
}
});
以下是我使用上述ajax代码时的错误消息:
The current request for action 'SaveBasicInformatio'' on controller type HomeController'
is ambiguous between the following action methods: System.Web.MVC.Action Result
SubmitRrquest(System.Web.formCollection)....
感谢您的帮助……属性“[MultipleButton]”是自定义属性吗?这可能会导致问题,因为它是一个ajax调用。尝试删除属性。是否尝试从操作方法中删除[MultipleButton]属性?是。。拆下后,它工作正常。。非常感谢你的帮助。我删除了所有按钮上的此属性。