Reputation: 472
I have list of objects which are returned from mvc controller as Json. I'm wondering how to display this objects on the view.
function GetTabData(xdata) {
$.ajax({
url: ('/Home/GetTabData'),
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ id: xdata }),
success: function (result) {
/// what to do here?
},
error: function () { alert("error"); }
});
}
public JsonResult()
{
...
var temp = getMyData...
return Json(temp, JsonRequestBehavior.AllowGet);
}
view page
<div id="showContent"> </div>
Upvotes: 1
Views: 3199
Reputation: 2016
Here is the first step you have to do :
success: function (result) {
/// what to do here?
result = jQuery.parseJSON(result);
/// Exploit your object(s) ;)
},
Look here for more details on the exploitation : http://api.jquery.com/jQuery.parseJSON/
Upvotes: 1