javascript - Terminate concurrent long polling Ajax HTTP requests -


i performing long polling via ajax request, listen database changes.

each time want listen value change send request follows :

$.ajax("http://system.host/dispatcher.php", {     method : "post",     datatype : "json",     data : "{value: 'user.username'}" });  $.ajax("http://system.host/dispatcher.php", {     method : "post",     datatype : "json",     data : "{value: 'user.age'}" }); 

=> tell php script want listen user.username , user.age values.

then when want notified above values send next long polling request, "notify request" :

$.ajax("http://system.host/dispatcher.php", {             method : "post",i             datatype : "json",             data : "{notify : true}",             success : function(result) {                  //success callback             },             failure : function(reply){                  //failure callback             },             error : function(){                 // error callback             } }); 

my problem don't want notify request duplicated in server side => explanation :

1) send notify request 1

----- notify request 1 sent (processing in progress).

2) send notify request 2

----- notify request 2 sent, should tell php script terminate "notify request 1" , send response client telling new notify request has replaced it, keep "notify request 2" running.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -