Henrik Petterson
Henrik Petterson

Reputation: 7094

jQuery: setInterval not working

I am attempting to run a setInterval via jQuery. The problem is that it is breaking my jQuery script completely. I suspect there is an error somewhere but I can't seem to find it, can you?

jQuery(document).ready(function(){
 setInterval(function() {

  jQuery.ajax({
    url: "admin-ajax.php",
    data : {action: "check_noti_log"},
    context: this,
    success:function(data){

         if(data.length == 0)
             // no new notification
         else
         {
             // the count is returned, insert it in the first a tag inside #wp-admin-bar-noti-bar list item
             jQuery('#wp-admin-bar-noti-bar').children().first().html(data);

             // change element id to new
             jQuery('#wp-admin-bar-noti-bar').attr('id','wp-admin-bar-noti-bar-new');
         }

    }
  });

 }, 60000);

});

Upvotes: 0

Views: 358

Answers (1)

lmarcelocc
lmarcelocc

Reputation: 1361

Look what you missed:

if(data.length == 0){ // This bracket

} // and the close one

Upvotes: 1

Related Questions