What is the proper way of doing long polling using jQuery and AJAX

I have a project which involves live notification. So I stumbled upon using socket io but I didn’t have enough time to learn it yet. So I tried doing it with AJAX and jQuery. Below is my code structure and I was wondering if this is gonna work with no drawbacks?

setInterval(function(){
  if( !element.hasClass('processing') ){
    element.addClass('processing');
    $.ajax({
      type:         'post',
      dataType:     'json',
      url:      ajaxurl,
      data:         {},
      success:  function( response ){
        /* Success! */
        element.removeClass('processing');
      }
    });
  }
}, 2500);

76 thoughts on “What is the proper way of doing long polling using jQuery and AJAX”

  1. pharmacie ouverte rennes pharmacie de garde aujourd’hui tarbes , pharmacie a bordeaux parapharmacie leclerc jonzac , DГіnde comprar Dutasteride pastillas, Comprar Dutasteride medicamento. Dutasteride en farmacia Guatemala Comprar Dutasteride genГ©rico [url=https://kit.co/fenravest/donde-comprar-dutasteride-pastillas-dutasteride-en-farmacia-guatemala#]DГіnde comprar Dutasteride pastillas[/url] pharmacie lafayette gambetta Doxycycline en farmacia Argentina, DГіnde comprar Doxycycline 200 mg. Doxycycline en farmacia Argentina Comprar Doxycycline genГ©rico [url=https://kit.co/riasale/comprar-doxycycline-sin-receta-doxycycline-en-farmacia-argentina#]DГіnde comprar Doxycycline 200 mg[/url] , comprime arrow generique pharmacie pas cher autour de moi , pharmacie de garde aujourd’hui finistere. pharmacie auchan nogent sur oise Azithromycin en farmacia Colombia, Comprar Azithromycin medicamento. Comprar Azithromycin sin receta Comprar Azithromycin genГ©rico [url=https://kit.co/enimec/azithromycin-venta-online-azithromycin-en-farmacia-colombia#]DГіnde comprar Azithromycin 1000 mg[/url] , pharmacie de garde ugine. pharmacie villesicard angers, pharmacie avignon rocade pharmacie lafayette ales . pharmacie annecy, therapie cognitivo-comportementale rabat pharmacie seraucourt bourges therapies work for .

    Reply

Leave a Comment