Ravi
Ravi

Reputation: 4085

jquery load div after page load

Actually what I am looking for loading is loading the page first and then a div with lots of data. So, I want to load the main page first and then body div content using jQuery function with some delay.

What is the simple way of implementing this..?

 <div id="container">
      <div id="header">navigation</div>
      <div id="body" class="body">Body</div>
      <div id="footer">footer</div>
 </div>

Upvotes: 2

Views: 29626

Answers (4)

Fery Kaszoni
Fery Kaszoni

Reputation: 4040

This is what I've done:

function newContent()
{
    $("#navix").load("new1.php");
}
$(function(){
  // Interval of 5 secs.
  setInterval("newContent()",5000);
  //http://www.w3schools.com/jsref/met_win_setinterval.asp
});

It works great ;)

Upvotes: 0

ankimal
ankimal

Reputation: 925

The shorthand version:

$(function(){
 $("#body").html();
 //...
});

If you want to do it after an interval

function load(){
 $("div").html(...);
}
$(function(){
  // Interval of 5 secs.
  setInterval("load()",5000);
  //http://www.w3schools.com/jsref/met_win_setinterval.asp
});

Upvotes: 3

Jan Zyka
Jan Zyka

Reputation: 17898

$(document).ready(function() {
  // Handler for .ready() called.
});

The ready function is called when page is fully loaded. You can load your div in it.

Upvotes: 0

FatherStorm
FatherStorm

Reputation: 7183

$(document).ready(function(){

  $.get('ajax/page.php', function(data) {
    $('#body').html(data);
  });

});

Upvotes: 9

Related Questions