When returning data from controller should I return Json?

When returning data from controller should I return Json?

Katrell01Katrell01 Posts: 8Questions: 2Answers: 0
edited July 2019 in Free community support

So I am trying to return the data from my controller to pass to my view for my DataTable , I am trying to implement ajax which allows me to load just the DataTable opposed to the whole page when I click a checkbox .

So initially I was returning my data as normal : return View(object) which displayed my DataTable correctly , but was getting an issue from my .js file b/c the data wasn't being returned correctly

So I changed the data being returned from my ActiomMethod to return json:** return Content(JsonConvert.SerializeObject(object), "application/json");**
but now my DataTable doesn't work properly it just displays the returned data as json

Please let me know if any additional information need to be provided.

Answers

  • kthorngrenkthorngren Posts: 20,345Questions: 26Answers: 4,776

    This seems to be a continuation of your other thread, correct?

    Kevin

  • Katrell01Katrell01 Posts: 8Questions: 2Answers: 0
    edited July 2019

    Yes, I can delete this post if its too close to my first post.

This discussion has been closed.