繁体   English   中英

从mvc返回对象作为json,如何显示在视图上

[英]returning object as json from mvc, how to display on the view

我有从mvc控制器作为Json返回的对象列表。 我想知道如何在视图上显示此对象。

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);   
}

查看页面

<div id="showContent"> </div>

这是您必须要做的第一步:

success: function (result) {
    /// what to do here? 
    result = jQuery.parseJSON(result);
    /// Exploit your object(s) ;)
},

在此处查看有关漏洞利用的更多详细信息: http : //api.jquery.com/jQuery.parseJSON/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM