Jquery Questions

Discussion in 'jQuery' started by dweebsonduty, Jul 11, 2009.

  1. #1
    I have code that refreshes a div every second, but for some reason the fadeIn only works the first time.

    Any Ideas?
     <script type="text/JavaScript">
      var refreshId = setInterval(function(){
         $("#quote p").load("script.php").fadeIn("slow");
     },1000);
     </script>
    
    Code (markup):
    I would also like this div to be added to and not replaced.

    Thanks
    -Shane
     
    dweebsonduty, Jul 11, 2009 IP
  2. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #2
    Figured it out, but the effect still only runs the first time.

    <script type="text/JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
     <script type="text/JavaScript">
    var runs = 0;
    function doSomethingWithData(data) {
        if (runs < 10)
        {
        $("#quote p").prepend(data);
        runs++;
        }
        else
        {
        $("#quote p").load('script.php').fadeIn("slow");
        runs = 0;
        }
    }
    
    window.setInterval(function() {
         $("#quote p").slideDown("slow");
     $.get('script.php', doSomethingWithData);
    }, 1000);
     </script>
    
    Code (markup):
     
    dweebsonduty, Jul 11, 2009 IP