I'm having some problems posting multiple parameters to my controller using AJAX.I want to pass model list and button name (string) to my controller.
jQuery:
function PostForm(buttonname) {
$.ajax({
url: "/ControllerName/ViewName",
type: "POST",
dataType: "application/JSON",
data:
JSON.stringify({
listOfObjects = $('#form').serialize(),
button : buttonname
})
});
};
partial view:
<input name="buttonname" value="Name" onClick="PostForm('Name')" />
Controller:
[HttpPost]
public ActionResult ViewName(List<MyObject> listOfObjects ,string button)
{
//Obj should now contain the list of objects and button name
}
On click of button,i am getting the value of button name but count of listobjects is 0.
How do I pass multiple params with different datatypes to the MVC method?
Ideas and suggestions greatly appreciated ! Thanks!