---
title: "How can I dynamically get data from ASP.NET MVC controller to jQuery?"  
description: "How can I dynamically get data from ASP.NET MVC controller to jQuery?"  
author: "Manish Kumar"  
published: 2017-06-11  
updated: 2017-06-11  
canonical: https://www.mindstick.com/forum/34305/how-can-i-dynamically-get-data-from-asp-dot-net-mvc-controller-to-jquery  
category: "c#"  
tags: ["c#", "mvc"]  
reading_time: 1 minute  

---

# How can I dynamically get data from ASP.NET MVC controller to jQuery?

I have a jQuery [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) that on the click of a [div element](https://www.mindstick.com/forum/34450/remove-div-element), gets that [elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) predefined ID value. What I want to do is load that [parent](https://www.mindstick.com/blog/154/how-to-find-parent-of-control-in-wpf) elements [children](https://yourviews.mindstick.com/view/81386/mobile-app-based-education-curse-or-boon-for-our-children), so I'm [planning](https://answers.mindstick.com/qa/32060/who-is-the-chairman-of-planning-commissison) to dynamically build some html using jQuery. What I don't know how to do, is make a call to a controller (mvc) and have the [controller return](https://www.mindstick.com/forum/12890/how-can-asp-dot-net-mvc-controller-return-an-image) a [collection](https://www.mindstick.com/articles/1718/collections-in-java) to the client.

I know how to send a JSON object from jQuery to a controller, but not the other way around.

Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by Sunil Singh

```
View jquery code  
$.ajax({         
url: '@Url.Action("GetData", "Home")',         
type: "GET",         
success: function (result) {              $("#somediv").append(result.FirstName);              $("#somediv").append(result.LastName);              $("#somediv").append(result.Age);         
}      });
```

Class code is

```
public class User       
{            public string FirstName { get; set; }            public string LastName { get; set; }        }
```

your action should look like this

```
public JsonResult
GetData()  {   User user = new User();  
user.FirstName = "Mindstick";  
user.LastName = "Software";  
user.Age = 100;    return Json(user, JsonRequestBehavior.AllowGet);}
```

Hope this will helps you..


---

Original Source: https://www.mindstick.com/forum/34305/how-can-i-dynamically-get-data-from-asp-dot-net-mvc-controller-to-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
