Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    jQuery load div x amount of seconds help

    I use the code below to reload a DIV with a file every X amount of seconds, problem is, on initial page load, it waits X amount of seconds before finishing loading the page and I need to come up with a way to load the DIV on page load immediately, then start refreshing it every X amount of seconds, any help appreciated, I am a newbie with ajax type stuff

    Code:
    <script>
    var auto_refresh = setInterval(
    function(){
    	$('#notificationcontainer').
            load('http://localhost/member/beta_new/notifications.inc.php').
            fadeIn("slow");
    }, 10000);
    </script>

    The above code loads this DIV

    <div id="notificationcontainer"></div>
    Last edited by jasondavis; 07-22-2009 at 06:28 PM.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    The right way to do it would be to load the data into the page from the server. There is no need to use Ajax to load the initial state.

    If you do not want it to wait, than break your code up into a function. Call the function. In the setTimeout, call the function.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •