I have a view that has been developed by another developer in which there is already code for a javascript that should handle the JSON Object and format as an HTML Table.
I'm new into MVC, and from the Controller, I create a JSON Object that contains what I need. The issue is that from my Controller, if I just return the JSON Object, then the browser just shows the raw JSON string to the client. It seems that when I return a JSON Object, the browser just shows the JSON, without actually calling my view that has the code to handle the JSON and making it user-friendly.
This is my controller:
public JsonResult GetPlayerNameByID(int playerID)
{
var player = GetPlayerByID(playerID);
return Json(player, JsonRequestBehavior.AllowGet);
}
This is called trough the on click event of a Dropdown List. The view for that page is like this:
@model FirstApp.Models.PlayerViewModel
<div id="container" class="container">
<table class="table player">
<thead>
<tr>
<th class="Name">Name</th>
<th class="Overall">Overall</th>
</tr>
</thead>
<tbody id="tableBody"></tbody>
</table>
I believe my issue is that the controller doesn't return to that view, but just a raw JSON Object. Any suggestion on how can I return to that view (this is the view from which the call has been made).