Hi Sir,
I have a controller which sends json data to a view and the view supposed to grab that json data and display in the datatable Ajax. but instead view is displaying just RAW json data.
my Controller code is -
- public ActionResult Index2()
- {
- using (Model_Test dbObj = new Model_Test())
- {
- List
testList = dbObj.Test_Table.ToList (); - var obj = new { data = testList };
- return Json(obj, JsonRequestBehavior.AllowGet);
- }
- }
my View code is -
- @{
- ViewBag.Title = "Index";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
"abc" class="display">
Id Name Address
- "~/Content/jquery.dataTables.min.css" rel="stylesheet" />
- @section Scripts{
- }
I tested the datatable with static data and it works fine. so it should be something to do with controller json output. Please help me I am so stuck.
Thanks
Sanwar RanwaRank #23 · 44.7K reputationPosted Jun 29, 2018, 4:19 AM EDT
How to retrive data using ajax in asp.net
Saminda Kotinkaduwa38 reputationPosted Jun 29, 2018, 7:57 AM EDT
Katrell Graham6 reputationPosted Jul 10, 2019, 8:32 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts