Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8613835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:58:37+00:00 2026-06-12T04:58:37+00:00

I am using .ajaxStart() and .ajaxStop() to show a modal while an ajax request

  • 0

I am using .ajaxStart() and .ajaxStop() to show a modal while an ajax request is being made. (between start and stop)

Now I’d like to add a longpoll function that keeps waiting for notifications, similar to the one on the left upper corner of this site.

My problem now lies in disabling this modal only for the longpolling request..

Registering “loading screen” on and off handlers:

$(document).ajaxStart(handleAjaxStart);
$(document).ajaxStop(handleAjaxStop);

My longpoll function:

$.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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:58:39+00:00Added an answer on June 12, 2026 at 4:58 am

    I figured it out..

    There is an attribute in the options object .ajax() takes called global.

    If set to false, it will not trigger the ajaxStart event for the call.

    $.ajax({
        timeout: 35000,
        url: longPollUrl,
        success: function(data){
            if(data.queCount) $('#numQueCount').html(data.queCount);
            if(data.queAccept) $('#numQueAccept').html(data.queAccept);
        }, 
        global: false,     // this makes sure ajaxStart is not triggered
        dataType: 'json',
        complete: longpoll
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spinner that displays when an ajax request is made using jquery:
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
How do you show ajax gif only for a specific request? For example my
I am using jquery ajax to load a separate page into a modal window
In Prototype, are there AJAX start/stop events that would allow you to create one
I followed the HTML5 Websocket tutorial of the website below: http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ It worked well,
When referring to this post here: http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ it tells you to run php -q
I am trying to do this on my xampp install. http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ When I get
How can I bind an ajaxStart function for a specific event, using : $(document).ajaxStart(function
I was in search of a way to show a status indicator using jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.