---
title: "Return List to ajax mvc3"  
description: "Return List to ajax mvc3"  
author: "Anonymous User"  
published: 2014-12-03  
updated: 2014-12-04  
canonical: https://www.mindstick.com/forum/12741/return-list-to-ajax-mvc3  
category: "asp.net"  
tags: ["ajax", "asp.net mvc", "mvc3", "listview"]  
reading_time: 1 minute  

---

# Return List to ajax mvc3

I am working on MVC3 and following is my [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc)

```
  public List<int> ddlTransType_Change(int DocID)        {             return UserDocumentServive.getSelectedUsers(DocID);         }
```

**My [Ajax](https://www.mindstick.com/articles/1541/check-availability-of-user-name-or-email-using-asp-dot-net-ajax-and-jquery)**

```
  $.ajax({                type: 'GET',                url:"/MIS.MVC/" + "DocumentApproval/ddlTransType_Change",                data:
{                   
'DocID': $("#ddlTransType").val().trim()                },               
success: function (result) {                   
alert(result.value)},error: function (e) {                   
alert("Error:Unable to load data from server");                }            });
```

Controller returns a list of [int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) [values](https://www.mindstick.com/forum/327/sum-textbox-values) [i.e](https://answers.mindstick.com/qa/39877/what-state-was-the-first-to-enter-the-union-i-e-was-the-first-to-ratify-the-united-states-constitution) {1,74,23,1} and I want to show them in [alert](https://answers.mindstick.com/qa/30927/what-is-an-alert). any idea how to do it .?

## Replies

### Reply by Anonymous User

If you are using MVC3, its better to return json data back to your ajax success call

```
public ActionResult ddlTransType_Change(int DocID)    {         List<int> list = UserDocumentServive.getSelectedUsers(DocID);;        return Json(new        {            list = list        },JsonRequestBehavior.AllowGet);    }
```

Then your ajax call changes to

```
 $.ajax({                type: 'GET',                url: "/MIS.MVC/" + "DocumentApproval/ddlTransType_Change",                data: {'DocID': $("#ddlTransType").val().trim()},                dataType: 'json',                success: function (result) {                                           var list=result.list;              $.each( list, function( index, value )                                         {                                            alert(value);                                           });                                             },error: function (e) {                    alert("Error:Unable to load data from server");                }        });
```


---

Original Source: https://www.mindstick.com/forum/12741/return-list-to-ajax-mvc3

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
