我正在使用jsrender绑定表。
我的代码
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="Script/jsrender.js" type="text/javascript"></script>
</head>
<body>
<a href="../demos.html">JsRender Demos</a><br />
<h3>Using {{if}} and {{else}} to render conditional sections.</h3>
<script id="movieTemplate" type="text/html">
<tr>
<td>{{>content_id}}</td>
<td>{{>Title}}</td>
<td>{{>content_type}}</td>
<td>{{>CreatedOn}}</td>
</tr>
</script>
<table>
<thead><tr><th>id</th><th>title</th><th>type</th><th>createdon</th></tr></thead>
<tbody id="movieList"></tbody>
</table>
<script type="text/javascript">
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/retieve_content_details",
data: "{ 'n_module_id' :1, 'n_number_of_records' :10}",
dataType: "json",
async: true,
success: function (data) {
$("#movieList").html(
$("#movieTemplate").render(data.d)
);
}
});
</script>
</body>
</html>
来自服务器端的数据是
[{ "content_id": 1, "Title": "Testing", "content_type": "Hyperlink", "rich_text": null, "URL": "http://www.google.co.in", "CreatedBy": "Wayne", "CreatedOn": "\/Date(1390947274213)\/" }, { "content_id": 2, "Title": "Testing Rich Text", "content_type": "Rich Text", "rich_text": "I think Intranet Content Management is also working fine.\u003cbr /\u003e\u003cbr /\u003ePlease test at staging. Locally its working fine.\u003cbr /\u003e\u003cbr /\u003eThanks \u003cbr /\u003eBhagirathi", "URL": null, "CreatedBy": "Wayne", "CreatedOn": "\/Date(1390947346907)\/" }];
当我在渲染中写入dara.d时它不能处理任何数据,但是如果复制数据并粘贴在一个对象上并使用该对象,那么数据将填充在表中。
喜欢
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/retieve_content_details",
data: "{ 'n_module_id' :1, 'n_number_of_records' :10}",
dataType: "json",
async: true,
success: function (data) {
var test_data = [{ "content_id": 1, "Title": "Testing", "content_type": "Hyperlink", "rich_text": null, "URL": "http://www.google.co.in", "CreatedBy": "Wayne", "CreatedOn": "\/Date(1390947274213)\/" }, { "content_id": 2, "Title": "Testing Rich Text", "content_type": "Rich Text", "rich_text": "I think Intranet Content Management is also working fine.\u003cbr /\u003e\u003cbr /\u003ePlease test at staging. Locally its working fine.\u003cbr /\u003e\u003cbr /\u003eThanks \u003cbr /\u003eBhagirathi", "URL": null, "CreatedBy": "Wayne", "CreatedOn": "\/Date(1390947346907)\/" }];
$("#movieList").html(
$("#movieTemplate").render(test_data)
);
}
});
以上代码正常运作。
请帮帮我
我在谷歌搜索并找到了一些很好的解决方案,但这些解决方案并不符合我的情况。
由于