将当前HTML与PHP AJAX调用返回的数据进行比较
I'm having issues comparing current list items on a page with ones that are retrieved through a PHP AJAX refresh. I only want the box to refresh if there are new items.
The PHP returns a bunch of formatted, HTML list items.
<ul class="socialFeed twitterFeed">
<script type="text/javascript">
$(function() {
refreshTweets();
});
function refreshTweets() {
$.get("php/tweets.php", function(data){
var current = $(".socialFeed.twitterFeed").html();
if(current != data) {
$(".socialFeed.twitterFeed").hide().html(data).fadeIn();
}
});
}
setInterval("refreshTweets()", 2000);
</script>
</ul>
I can't figure out why the string comparison isn't working. I'm missing something, but I'm not sure what.
douhunkuang8955
2013/01/08 20:51- php
- ajax
- string-comparison
- jquery
- 点赞
- 收藏
- 回答
满意答案
1个回复
