I am using .ajaxStart() and .ajaxStop() to show a modal while an ajax request is being made. (between start and stop)
现在我想添加一个longpoll函数,它会一直等待通知,类似于这个网站左上角的那个.
My problem now lies in disabling this modal only for the longpolling request..
注册"加载屏幕"打开和关闭处理程序:
$(document).ajaxStart(handleAjaxStart);
$(document).ajaxStop(handleAjaxStop);
我的LongPoll函数:
$.ajax({
timeout: 35000,
url: longPollUrl,
success: function(data){
if(data.queCount) $('#numQueCount').html(data.queCount);
if(data.queAccept) $('#numQueAccept').html(data.queAccept);
},
dataType: 'json',
complete: longpoll
});
I tried:
$().off('ajaxStart');
$().off('ajaxStop');
..and reattaching the handlers after starting the polling, but no joy.
I also tried introducing a global variable into handleAjaxStart()
that would return at the first line of the function, but that seems to completely kill the loading screen.
Any ideas how this can be achieved?