【发布时间】:2011-07-02 13:51:12
【问题描述】:
我从我的服务调用中得到这个 JSON 响应:
[Object { __type="TestDTO:#TestServer.Data", DateCreated="/Date(1298357607157+0500)/", more...}, Object { __type="TestDTO:#TestServer.Data", DateCreated="/Date(1298357628953+0500)/", more...}]
我想使用需要 javascript 数组的 Jquery 模板
喜欢:
var books = [
{ title: "ASP.NET 4 Unleashed", price: 37.79, picture: "AspNet4.jpg" },
{ title: "ASP.NET MVC Unleashed", price: 44.99, picture: "AspNetMshed.jpg" },
{ title: "ASP.NET Kick Start", price: 4.00, picture: "AspNetKickStart.jpg" },
{ title: "ASP.NET MVC Unleashed iPhone", price: 44.99, picture: "Asele.jpg" },
];
如何将 JSSON 响应转换为以下格式(请忽略数据)只是格式应该相同。
我在ajax成功方法中使用这个:
success: function (response) {
var tr = response.d;
var tests = tr.Tests;
$("#TestsTemplate").tmpl(tests).appendTo("#divTests");
.tmpl(tests) 需要 javascript 数组
Mu Jquery 模板如下所示:
测试名称:${TestName}
测试页:${TestPage} 编号:${ID} 创建日期:${DateCreated} 结果:${结果} 状态:${状态} <div id="divTests">
</div>
我从 json 得到的是下面的 DTO
公共类TestRunDTO { 公共长 ID { 获取;放; } 公共字符串 TestSuiteName { 获取;放; } 公共日期时间 DateCreated { 获取;放; } 公共 int 结果 { 获取;放; } 公共 int 状态 { 获取;放; } 公共列表测试{获取;放; } }
我想使用 jquery 模板在 TestRunDTO 中显示这个测试集合
问候, 阿西夫·哈米德
【问题讨论】: