Sakshi Sharma
Sakshi Sharma

Reputation: 1472

setTimeout Not Returning value

I am using setTimeout for getting new data at interval of 30 seconds, but it's not working, don't know where it's messed up. Here is my code:

(function pollmsg() {
    setTimeout(function () {
        var demon = $('.msgnotimore').val();
        var a = $('.gvpgvpxgvp').val();
        $.ajax({
            url: 'modules/notifications/beast.php?nid=' + demon + '&id=' + a,
            success: function (data) {
                $('.notiloadmsg').append($(data).fadeIn('slow'));
                alert(data);
            },
            dataType: "json",
            complete: pollmsg
        });
    }, 30000);
})();

When I try to alert demon, it alerts demon after 30 sec, but the data is not alerted.

Upvotes: 0

Views: 114

Answers (1)

matt3141
matt3141

Reputation: 4423

dataType: "json" should not be used when fetching HTML instead use "html"

Upvotes: 3

Related Questions