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

  • SEARCH
  • Home
  • 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 8564609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:14:19+00:00 2026-06-11T17:14:19+00:00

I have several ajax requests in a script, some sync some async I use

  • 0

I have several ajax requests in a script, some sync some async I use a pload.gif to display when an ajax request is active for more than 1 second. I found that in one circumstance the pload.gif continued to display even though the request was successful and the expected actions completed. N:B: no other request has been fired i.e. $.active = 1. But ajaxStop does not fire furthermore I have tested ajaxComplete and ajaxSuccess (not that I want these as I want to capture any async request) and these also do not fire either.

Here is the offending request:

$.ajax({
    beforeSend: function(){
        $("#loading p").append("validate class schedules");
        console.log("validate class schedules");
    },
    type: "POST",
    url: "../_admin/admin_Validate_Class_Schedule.php",
    data: {class_Key: current_Class_Key, schedule_Key : current_Schedule_Key},
    dataType: "text",
    async: false,
    success: function(return_Data){
        console.log("success");
        var result = $.trim(return_Data);
        console.log("result: " + result + " " + "call count: " + call_Count + " : " + $("#schedule_Description").val() + " " + $("#schedule_Description").val().length + " " +  current_Class_Key);

        if (result == "exists"){
            $("#create_Schedule .form_Submit").attr("value", "Update Schedule");
            $("#create_Schedule").attr("action", "process_Schedule_Update.php");
            $(".form_Footer .form_Submit").css("color", "#fff");
            $(".form_Footer .form_Submit").removeAttr("disabled");                  
        } else {
            $("#create_Schedule .form_Submit").attr("value", "Create Schedule");
            $("#create_Schedule").attr("action", "process_Schedule_Create.php");
            $(".form_Footer .form_Submit").css("color", "red");
            $(".form_Footer .form_Submit").attr("disabled","disabled");             
            if ((current_Class_Key.length != 0) && ($("#schedule_Description").val().length != 0)){
                $(".form_Footer .form_Submit").css("color", "#fff");
                $(".form_Footer .form_Submit").removeAttr("disabled");
            }
        }   
    },
    error: function(){
        console.log("Validate Could not retrieve XML file.");
    }
});  // end ajax call

My temptation is to use the following at the end of the success branch

if ($.active == 1){                // nothing else requested which should be the case
   $.event.trigger( "ajaxStop" );  // force a stop
   $.active = 0;                   // force active to zero as belt and braces as not
}                                  // sure if triggering stop will set active to zero

However I am unsure – is this storing up a problem for later on and why should this be necessary anyway. I don’t want to have to start coding this in all my requests. I want all my requests to decrement $.active when finished. So I suppose the real question is why is this not so?

Any thoughts welcomed.

  • 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-11T17:14:19+00:00Added an answer on June 11, 2026 at 5:14 pm

    Maybe not a direct answer to you question of why it doesn’t seem to fire, but too lengthy for a comment and possibly a way around your problem:

    You can use jQuery’s new Deferred system to attach ajax callbacks. The ajax call on the jQuery object returns a deferred object:

    var dfd = $.ajax({
                  beforeSend: function(){
                      $("#loading p")
                          .append("validate class schedules");
                      console.log("validate class schedules");
                  },
                  type: "POST",
                  url: "../_admin/admin_Validate_Class_Schedule.php",
                  data: {class_Key: current_Class_Key, schedule_Key : current_Schedule_Key},
                  dataType: "text",
                  async: false
              });
    

    You can attach your callbacks on this object using deferred.then, deferred.done, deferred.fail:

    dfd.done(function(){
        // ajax succes, handle
    });
    dfd.fail(function(){
        // ajax failure, handle
    });
    
    // OR
    
    dfd.then(function(){
        // ajax succes, handle
    }, function(){
        // ajax failure, handle
    });
    

    Once the deferred object gets ‘resolved’ (this happens when the ajax call is completed, or fails), the appropriate callbacks are called. Even if you attach a callback when it is already resolved, your callback will fire immediately (if appropriate of course)

    This is the new way of doing things in jQuery and it can save you a lot of headaches! It’s clean and makes dealing with asynchronicity a lot easier.

    More info in the docs here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
I have several ajax requests that return different values (pseudocode ahead) var foo =
Several of my ajax applications in the past have used GET request but now
I have several popovers (on a tags) that make ajax calls to populate their
I have several DropDown controls on a Web Form which are filled using AJAX
I have a page that has several ajax submission forms. Each form has a
I have an application that uses AJAX liberally. I have several places where a
I have several Delphi programs that maintain connections to a database (some Oracle, some
So, I have a page that loads and through jquery.get makes several requests to
I'm developing a website using PHP+Ajax. I have to fire a ajax request that

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.