jQuery - Multiple setInterval Conflict

Posted by Chris Bowyer on Stack Overflow See other posts from Stack Overflow or by Chris Bowyer
Published on 2011-02-07T23:07:28Z Indexed on 2011/02/07 23:25 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

I am a jQuery novice and each of the following work fine on their own, but get out of time when working together. What am I doing wrong? Any improvement on the code would be appreciated too... It is to be used to rotate advertising.

<!--- Header Rotator --->
<script type="text/javascript">
$(document).ready(function() {
    $("#header").load("header.cfm");
    var refreshHeader = setInterval(function() {
        $("#header").load("header.cfm");
    }, 10000);
});
</script>
<!--- Main Rotator --->
<script type="text/javascript">
$(document).ready(function() {
    $("#main").load("main.cfm");
    var refreshMain = setInterval(function() {
        $("#main").load("main.cfm");
    }, 5000);
});
</script>
<!--- Footer Rotator --->
<script type="text/javascript">
$(document).ready(function() {
    $("#footer").load("footer.cfm");
    var refreshFooter = setInterval(function() {
        $("#footer").load("footer.cfm");
    }, 2000);
});
</script>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about multiple