我有一个个人资料页面,用户可以在其中上传自己的评论。
上传评论的代码是json格式的。
jQuery模板
来自 Chrome JSON 预览的 JSON 响应示例:
"并且评论内容没有被解析为HTML,只是字符串。"
上传评论的代码是json格式的。
$('#profile-comment .stream-more-link').click(function (e) {
e.preventDefault();
//Increment stream page
streamPage++;
//Get post data in json
$.ajax({
url : "/profile/comments",
dataType: "json",
data: {"page":streamPage},
success: function(response) {
if (response.length > 0) {
$('#commentTmpl').tmpl(response).appendTo('.stream-items');
} else {
$('.stream-more').hide();
}
}
})
return false;
});
jQuery模板
<script type="text/x-jquery-tmpl" id="commentTmpl"></script>
来自 Chrome JSON 预览的 JSON 响应示例:
8: {post:[],…}
comment: {id:46298, content:<i>проверка</i>, на то как<b> </b><b><i>работает</i></b><b> </b>очистка.<br>,…}
content: "<i>проверка</i>, на то как<b> </b><b><i>работает</i></b><b> </b>очистка.<br>"
date: "20.09.2011 02:22"
id: "46298"
post: []
user: {name:moderator, link:/profile/view/username/moderator,…}
foto: "/files/user/fotos/thumb/default.jpg"
link: "/profile/view/username/moderator"
name: "moderator"
9: {post:[], comment:{id:46303,…}, user:{name:moderator, link:/profile/view/username/moderator,…}}
comment: {id:46303,…}
content: "Содержимое с <b>HTML</b>-<i>разметкой <img src="/files/emoticons/love.gif" alt="love" title="love" /><br></i>"
date: "20.09.2011 02:19"
id: "46303"
post: []
user: {name:moderator, link:/profile/view/username/moderator,…}
foto: "/files/user/fotos/thumb/default.jpg"
link: "/profile/view/username/moderator"
name: "moderator"
"并且评论内容没有被解析为HTML,只是字符串。"