到目前为止,我知道我可以使用AJAX分离静态和动态内容,所以如果博客文章有评论更新,文章就不必重新下载(它应该是304),只有注释。现在,我正在考虑坚持获取的动态内容,以便下次只需要新的评论。在不依赖Flash/Gears/ other 5存储或其他插件的情况下,有办法做到这一点吗?
编辑:假设文章的注释部分如下所示:
<div class='comments' id='comments'>
<a name='comments'></a>
<h4>43 comments:</h4>
<dl id='comments-block'></dl>
<p class='comment-footer'>
<a href='http://example.org/postcomment' onclick=''>Post a Comment</a>
</p>
</div>在此上,获取注释的AJAX调用将它们附加到<dl id='comments-block'>,其中包含以下代码段:
<div class='comments-singleblock'>
<dt class='comment-author' id='comment-5378479254070788764'>
<a name='comment-5378479254070788764'></a>
Anonymous coward
<span class='comment-timestamp'>
<a href='#comment-5378479254070788764' title='comment permalink'>
5 February 2012 16:52
</a>
</span>
</a>
</dt>
<dd class='comment-body'>
<p>
Your lorum is my ipsum, the dolor is sit amet us.
</p>
</dd>
<dd class='comment-footer'>
Which eternal lies, that is not death.
</dd>
</div>可以缓存。随后的AJAX调用应该只返回新的内容,并附加到上面。现在,当文章加载时,逻辑是这样的
不带时间戳的
。
因此,问题在于如何修改缓存的内容以包括时间戳A和B之间的内容。
发布于 2012-08-14 19:47:23
创建一个局部变量来存储ajax调用的JSON结果。
创建一个局部变量来存储Max_Last_Modified_Date。
创建一个javascript助手,它将绘制JSON结果。
创建一个服务器端处理程序,它将告诉您您的评论的最大(LastModifiedDate)。
创建一个服务器端处理程序,它将返回JSON中的注释
所有结果(第一个fetch)
之后的修改日期)
https://stackoverflow.com/questions/5230185
复制相似问题