Reputation: 85
I have a page in php and I need to refresh only a div of this page
<body>
.... page code here ....
?><div id="chattext">
<div id="list"><ul><?php
echo "ttt ".time();
... code php ...
</body>
In head tag I hage this 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 is that che the first time reload all page inside the block and only from the second time reload correctly only the div.... Why??? how can I resolve the problem???
Upvotes: 1
Views: 3906
Reputation: 207557
In the code where you load the page fragment
$('#chattext').load(url + '#list');
It needs to have a space between the url and the fragment identifier
$('#chattext').load(url + ' #list');
Upvotes: 3