0

这是主要代码。请检查一下。是什么造成了这种冲突。

<script type="text/javascript">
$(document).ready(function () 
{
  setInterval(function() 
  {
    $.get("ajax_files/manage_friend_requests.php", function (result) 
    {
      $('#all_friends_requests').html(result); // This is the div i am reloading again and again after some seconds.
          });
        }, 9000);
    });
</script>
4

1 回答 1

0

您应该使用以下方式更安全:

$(document).ready(function(){
    setInterval(function(){
        $.ajax({
            type: "GET",
            url: "ajax_files/manage_friend_requests.php"
        }).done(function(result) {
            var $friends_requests = $('#all_friends_requests');
            if ($friends_requests.length > 0) {
                console.log('Received: '+result);
                $friends_requests.html(result);
                console.log('UPDATED friends requests');
            } else {
                console.log('CANNOT access friends requests container');
            }
        });
    }, 9000);
});

根据控制台将显示的内容,您可能会发现问题。

于 2013-08-13T19:09:42.710 回答