防新浪微博评论功能实现
现在,我有这样一要需求。就是防新浪微博评论的数据实现。ajax实现
点击评论,传送一个ID过去,得到所有回复数据.然后显示在下面。这个要怎么实现呢?
而且还我还要跟他一样,点评论后马上显示?
通过AJAX实现。
[解决办法]
你都知道传ID过去用ajax实现了,还不会写嘛
[解决办法]
传递过去后 ajax 返回json js 读取js 将数据呈现到浏览器
[解决办法]
var dt = '{"data":[{"commentid":"1","weiboid":"47","uid":"100001","content":"34535","datetime":"1350355452","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"},{"commentid":"2","weiboid":"47","uid":"100000","content":"34535","datetime":"1350355456","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"},{"commentid":"3","weiboid":"47","uid":"10016","content":"34535","datetime":"1350355471","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"},{"commentid":"37","weiboid":"47","uid":"100000","content":"656321","datetime":"1350355517","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"}],"total_rows":4}';
var json = eval('(' + dt + ')');
$(json.data).each(function(i, item){
alert(item.commentid)
})