Jump to content


Photo

jquery delaying load


  • Please log in to reply
1 reply to this topic

#1 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 17 February 2011 - 09:10 PM

okay, so the entire process works fine, to a certain degree. What I'm wanting is when the div gets animated to 1px, it delays THEN loads the page before it animates back to the original size...

below is my source:
$(document).ready(function() {
$("a#f").click(function() {
$("#div").animate({height:"1px"},"slow");
$("#div").delay(1000);
$("#div").load("page.html");
$("#div").animate({height:"200px"},"slow");
});
});

Any suggestions??? It will do all the above, except it wont delay the page loading like I want.

Edited by derek.sullivan, 17 February 2011 - 09:11 PM.


#2 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 18 February 2011 - 01:24 AM

The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

Since load isn't an effect, it's an ajax request, it doesn't get delayed. To delay the load, you'll have to use setTimeout().

i.e.
setTimeout(function (){ $('#div').load('page.html'); }, 1000);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users