---
title: "Passing array from ajax to controller"  
description: "Passing array from ajax to controller"  
author: "Anonymous User"  
published: 2014-01-25  
updated: 2014-01-25  
canonical: https://www.mindstick.com/forum/1875/passing-array-from-ajax-to-controller  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Passing array from ajax to controller

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to pass an [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) from [ajax](https://www.mindstick.com/articles/1541/check-availability-of-user-name-or-email-using-asp-dot-net-ajax-and-jquery) to [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc), but I am not getting the [values](https://www.mindstick.com/forum/327/sum-textbox-values) in controller

**below is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)**

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();        }
```

## Replies

### Reply by Pravesh Singh

Hi Jacob,

Your code should be like this

```
     $.ajax({          url:"Home/userDetails",          data: {             
"UserDetailsParam":JSON.stringify(userDetails)//change this          },         
responseType: "json",          success:
successfn,          error:
errorfn      });
```


---

Original Source: https://www.mindstick.com/forum/1875/passing-array-from-ajax-to-controller

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
