I am trying to pass an array variable from ajax to controller, but I am not getting the values in controller
below is my code
AJAX
function userDetailsClass() {
var userDetails = {};
userDetails.age = 12;
userDetails.Name = "Vignesh";
userDetails.lastName = "s";
debugger;
$.ajax({
url: "Home/userDetails",
data: JSON.stringify({
UserDetailsParam: userDetails
}),
responseType: "json",
success: successfn,
error: errorfn
});
function successfn(result) {
};
function errorfn(result) {
};
}
Controller
public ActionResult userDetails( string UserDetailsParam){
return View();
}
I also tried
public ActionResult userDetails( string[] UserDetailsParam){
return View();
}
Pravesh Singh
25-Jan-2014Your code should be like this