2

我在我的视图页面上声明并序列化了数据

@model IEnumerable<MVCvs2012.Models.Employees>

 @{
    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    var employees = @serializer.Serialize(ViewData["Employees"]);   
  }

运行浏览器时的结果:

[{"FirstName":"Nancy","LastName":"Davolio","Title":"Sales Representative"}]

我想使用 jquery 将这些数据呈现到这样的表中:

<table id="employee">
<tr>
  <td>Nancy</td>
  <td>Davolio</td>
  <td>Sales Representative</td>
</tr>
...
</table>
4

1 回答 1

1

使用jQuery.each构建您的表格。类似的东西

$var table = '<table>';
$.each(yourJson, function( index, value ) {
      $table += '<tr><td>' + value.FirstName + '</td><td>' + ...
});
$table += '</table>';
于 2013-09-26T17:03:27.267 回答