试图实现无限滚动,用php,smarty和jquery ajax。正如我理解的最佳方式,而不是加载服务器很多是获得响应作为JSON格式的数据,并做客户端的所有过程。事情是,我想通过聪明的功能。 只是一段代码,供各位的意见,了解我的意思:是否可以将smarty函数传递给json html输出?
$.each(data.content, function(key, value){
if(value.comment !=''){
//When it comes to date, smarty is working and is implementing date_format
html += '<div class="timeline-date"><i class="fa fa-calendar"></i>
{'+value.date+'|date_format:"%B %d, %Y %I:%M %p"}</div>';
html += '</div>';
//But when it comes to comment itself, smarty functions are not working
html += '<p>{'+value.comment+'|smarty_modifier_autolink|nl2br|mention}</p>';
}
}
与评论第二个例子我都在浏览器中得到的是+value.comment+
,而不是评论本身。 我一般不太会用json
或javascript
,也许还有其他一些方法来渲染html使它可以使用smarty
函数?感谢大家!
如果您在客户端编写此代码,您将无法再次通过smarty处理生成的HTML ... – m13r
如何处理生成的HTML代码? – m13r
对不起,我不明白这个问题。你什么意思? –