Chenthamizh
Chenthamizh

Reputation: 1

Ajax is Hanging

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>

Upvotes: 0

Views: 222

Answers (1)

Parfait
Parfait

Reputation: 1750

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

Upvotes: 1

Related Questions