weixin_33682719 2014-07-05 04:30
浏览 5

Ajax挂了

I am developing my website with ajax and php scripts. My web page is hanging by the following ajax script. How should I want modify the script to avoid hanging

<script>
$(function(){       
    $('#popModal_ex2').click(function(){
        $('#popModal_ex2').popModal({
            html : function(callback) {
            setInterval(function() {
                $.ajax({url:'notification_message.php'}).done(function(content){
                    callback(content);
                    }, 4);
                });
            }
        });
    });
});
</script>
  • 写回答

1条回答 默认 最新

  • weixin_33738555 2014-07-05 05:03
    关注

    The reason of hanging is the second parameter of setInterval() is missing , it will execute the ajax call "every second"

    $('#popModal_ex2').click(function(){
        $('#popModal_ex2').popModal({
            html : function(callback) {
                setInterval(function() {
                    $.ajax({
                        url:'notification_message.php',
                    }).done(function(content){
                        callback(content);
                    });
                }, 6000); // every 6 second
            }
        });
    });
    
    评论

报告相同问题?