Hi, I'm having a problem with comparing the returned string from the Ajax responseText variable. I want my code to do this:
1. GET NewsFeed.php
2. ONLY IF result is different from text in DIV "NewsFeed", then animate NewsFeed (using jQuery) and update the data in NewsFeed.
The problem is, though, is that the NewsFeed DIV is faded out and then in, every time (even when the NewsFeed.php is not changed). So this means that, for some reason, I can't use != on these two string values. Am I doing something wrong?HTML Code:function updateNewsFeed() { xmlhttp1=new XMLHttpRequest(); xmlhttp1.onreadystatechange=function() { if (xmlhttp1.readyState==4) { if (document.getElementById("NewsFeed").innerHTML != xmlhttp1.responseText){ $("#NewsFeed").fadeOut("fast", function(){ document.getElementById("NewsFeed").innerHTML=xmlhttp1.responseText; $("#NewsFeed").fadeIn("fast"); }); } } } xmlhttp1.open("GET","NewsFeed.php"); xmlhttp1.send(); var t = setTimeout("updateNewsFeed()",10000); }


Reply With Quote

Bookmarks