javascript - Refresh div without reload the page with jquery -
i have page in php , need refresh div of page
<body> .... page code here .... ?><div id="chattext"> <div id="list"><ul><?php echo "ttt ".time(); ... code php ... </body>
in head tag hage code
<script> $(document).ready(function() { $.ajaxsetup( { cache: false, beforesend: function() { $('#chattext').hide(); //$('#loading').show(); }, complete: function() { //$('#loading').hide(); $('#chattext').show(); }, success: function() { //$('#loading').hide(); $('#chattext').show(); } }); var url='index.php'; var refreshid = setinterval(function() { $('#chattext').load(url + '#list'); }, 3000); });
the problem che first time reload page inside block , second time reload correctly div.... why??? how can resolve problem???
in code load page fragment
$('#chattext').load(url + '#list');
it needs have space between url , fragment identifier
$('#chattext').load(url + ' #list');
Comments
Post a Comment