jquery $.post firing twice on one call
Hello,
I made a small device which posts data to a PHP page using $.post and dumps the echoed string into a div.
My problem is even though $.post is written only once and fired only once per given interval, it's doing it twice an interval.
I have tried reverting the php page to an ASP page, with no result. It's doing it twice as well on the asp page.
Here's the Javascript:
-
$(document).ready(function(){
$("div#reviewWrap div").html("");
function fetchReview(){
$("div#reviewWrap div").fadeOut(function(){
$.post("/includes/get_reviews/get_reviews.asp",{getReview:1},function(data){
returnData = data;
returnDataLen = returnData.length
if(returnDataLen != 0)
{
$("div#reviewWrap div").html(returnData);
$("div#reviewWrap div").fadeIn(function(){
var contentHt = $("div#reviewWrap div").outerHeight();
contentHt = contentHt + 30
$("div#reviewWrap").animate({height: contentHt});
});
} //if(returnDataLen !=0)
}); //$.post(
}); // $("div#reviewWrap div").fadeout
} //function getReview()
setInterval(fetchReview, 10000);
});
I will not be posting the Server Side code as I'm quite confident there is no problem there, (i tried both ASP and PHP solutions and both times behaviour was same So definetely a problem in jQuery or my Javascript).
How do people do this? Is there another way? Any help or advice to make this code more efficient or more workable will be greatly appreaciated! Thank you! Ya Ha
