試圖實現無限滾動,用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
對不起,我不明白這個問題。你什麼意思? –