Jquery jsrender在ajax调用中不起作用

Jquery jsrender在ajax调用中不起作用,jquery,jsrender,Jquery,Jsrender,我正在使用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"&g

我正在使用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>
当我在渲染中写入dara.d时,它不会处理任何数据,但如果复制数据并粘贴到对象上并使用该对象,则数据将填充到表中

以上代码正在运行

请帮帮我

我在谷歌上搜索,找到了一些不错的解决方案,但这些都不适合我的情况


谢谢

当您从ajax模块调用
.render
时,是否有任何错误?@dreamweiver:没有。它只是显示空tr。嘿,您不认为您的ajax调用应该在
$(文档)范围内。准备就绪(function(){//ajax call here})
显然是的,如果您试图在加载时进行ajax调用,那么它应该在您可能希望随时触发的函数中。事实上,我认为现在在您的代码中甚至不需要进行ajax调用。裁判:
[{ "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)\/" }];
$.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)
        );
    }
});