Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.

Post Page Advertisement [Top]

Refresh a particular div jQuery

Method 1:
How to refresh a particular div content when page is loading through ajax load() function

<ul id="nav" class="nav" style="font-size:12px;">
<li><a href="#" data-url="location.html">Location</a></li>
<li><a href="#" data-url="multi.html">Multi-Location</a></li>
<div id="home"></div>

$('#nav a').on('click', function(e){
     $('.active').removeClass('active'); // removes the active class from other link
     $(this).addClass('active'); // adds the active class to current cliked link
       $("#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.

Method 2:
Refesh Particular div by jquery. 
$("#userRecord").load(location.href+" #userRecord>*","");

Method 3:
<script src=""></script>
     }, 5000);
function autoRefresh_div()
$("#result").load("load.html");// a function which will load data from other file after x seconds


No comments:

Post a Comment

Bottom Ad [Post Page]