我想在我的php页面上使用JTemplate。我的模板:
<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>来自Service.php的Json数据是正确的。但我得到以下错误:“无法读取属性‘长度’的未定义”我做错了什么?
发布于 2011-11-21 18:23:39
尝试:
添加
$.ajax
({
dataType:"json" , ...https://stackoverflow.com/questions/8209175
复制相似问题