使用 jquery 刷新 div 而无需重新加载页面

Refresh div without reload the page with jquery

我在 php 中有一个页面,我只需要刷新此页面的一个 div

<body>
 .... page code here ....
?><div id="chattext">
            <div id="list"><ul><?php
                echo "ttt ".time();
                ... code php ...
</body>

在 head 标签中我有这个代码

<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);
});

问题是 che 第一次重新加载块内的所有页面,只有从第二次正确重新加载 div... 为什么???我该如何解决这个问题???

在加载页面片段的代码中

$('#chattext').load(url + '#list');

在url和片段标识符

之间需要有一个space
$('#chattext').load(url + ' #list');