forum

Home / DeveloperSection / Forums / Passing array from ajax to controller

Passing array from ajax to controller

Anonymous User 2562 25-Jan-2014

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();
        }

c# c# 
Updated on 25-Jan-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By