JT模板错误
问题描述:
我想在我的php页面上使用JTemplate。我的模板:JT模板错误
<script type="text/html" id="TemplateResultsTable">
{#template MAIN}
<table cellpadding="10" cellspacing="0">
<tr>
<th>Seller</th>
<th>Bid Amount</th>
<th>Date</th>
</tr>
{#foreach $T.d as CD}
{#include ROW root=$T.CD}
{#/for}
</table>
{#/template MAIN}
{#template ROW}
<tr>
<td>{$T.Bidder}</td>
<td>{$T.Bid}</td>
<td>{$T.BidDate}</td>
</tr>
{#/template ROW}
</script>
我的Ajax调用:
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
$('#ctl0_Main_BidHistoryPortlet_ctl0').click(function(){
$.ajax
({
type: 'POST',
url: '/index.php/page,Service',
data: 'action=TestFunction&AuctionId='+$('#ctl0_Main_BidHistoryPortlet_AuctionId').val(),
success: function(msg)
{
ApplyTemplate(msg);
}
});
});
function ApplyTemplate(msg)
{
$('#Container').setTemplate($("#TemplateResultsTable").html());
$('#Container').processTemplate(msg);
}
});
</script>
JSON数据是来自Service.php是正确的。但我得到以下错误: “无法读取未定义的属性”长度“ 我做错了什么?
答
尝试:
加入
$.ajax
({
dataType:"json" , ...
当我添加数据类型: “JSON” 我得到以下错误 “无法读取的未定义的属性 'd'” –