[Solved] how to refresh a particular div content when page is loading through ajax load() function


I suggest you to use .data() method of jQuery to provide required extra info:

<ul id="nav" class="nav" style="font-size:12px;">
    <li><a href="#" data-url="https://stackoverflow.com/questions/24553150/tab1.php">Tab1</a></li>
    <li><a href="#" data-url="tab2.php">Tab2</a></li>
    <li><a href="#" data-url="tab3.php">Tab3</a></li>
</ul>

As you are using jQuery then better to use unobtrusive way of writing scripts like this:

$('#nav a').on('click', function(e){
     e.preventDefault();
     $('.active').removeClass('active'); // removes the active class from other link
     $(this).addClass('active'); // adds the active class to current cliked link
     setInterval(function(){
       $("#home").load($('.active').data('url'),{},function(){}); // populates the div with data-url of active class.
     }, 5000);
});
 $('#nav li:eq(0) a').trigger('click'); // triggers the first link's click.

7

solved how to refresh a particular div content when page is loading through ajax load() function