javascript - Jquery fadeIn in callback for fadeOut not lasting -
hope can shed light on issue me.... i'm using setinterval alternate displaying headlines on webpage. fades out previous one, in callback function fades in new one. used work fine, separated callback function fadeout because wanted run without delay, , i'm getting initial headline, when comes time change, fade in split second , disappear again.
function processsidebar(data) { var headlines = $.parsejson(data); var sindex = 0; function newsidebar(surl, sindex) { $(".sidebar").html(headlines[sindex].date + '<br><a href="' + surl + '">' + headlines[sindex].line + '</a>'); $(".sidebar").fadein(400); } newsidebar("getme.php?blog=1&headline=1", sindex); setinterval(function() { ++sindex; if (sindex == headlines.length) {sindex = 0} var surl="getme.php?blog=1&headline=" + headlines[sindex].index; $(".sidebar").fadeout(400,newsidebar(surl,sindex)); }, 10000); // end setinterval }; // end processsidebar
jquery's fadeout
wants function complete
argument.
you're giving newsidebar(surl,sindex)
, gets evaluated , returns nothing (but whole fadein
stuff).
you want use anonymous function:
$(".sidebar").fadeout(400,function() { newsidebar(surl,sindex) });
Comments
Post a Comment