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 6742475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:50:52+00:00 2026-05-26T11:50:52+00:00

I have an AJAX POST function. I want to obtain a successful callback then

  • 0

I have an AJAX POST function. I want to obtain a successful callback then execute a function. I chose to achieve this with $.when as follows

var url = '/echo/html/';
var json_text = ' ';
var FireOrderCounter = 0;

$.when(
        $.ajax({
        type: 'POST',
        url: url,
        data: json_text,
        success: function () {
            FireOrderCounter++;
            alert('successfully completed Action ' + FireOrderCounter);

            var millisecondsToWait = 5000;
            setTimeout(function() {
                FireOrderCounter++;
                alert('Done Spinnin ' + FireOrderCounter);
            }, millisecondsToWait);


        },
        dataType: 'html'
    })
).then(openWindow());


function openWindow() {
     FireOrderCounter++;
     alert('opened window' + FireOrderCounter );
}

success callback fires after openWindow(). Does this mean that $.ajax is somehow not deferred and $.when is simply assuming success as described in the API?

If a single argument is passed to jQuery.when and it is not a
Deferred, it will be treated as a resolved

This is a simplified test case. The production code fails similarly. I have to fire this event twice to obtain all the data. There is a race condition.

I can insert a breakpoint to make the processing stop. The Function fires while I am still holding onto the debugger. So, its not waiting for a success callback. A short timeout (occurs after ~10 seconds)? How can I fix this?

  • 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-05-26T11:50:53+00:00Added an answer on May 26, 2026 at 11:50 am

    I think it’s your then statement: .then(function(){openWindow()}); or .then(openWindow). If you pass with () it will execute the function.

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

Sidebar

Related Questions

i have an ajax function for uploading photos, and this function is executed onclick.
I have the following Ajax call: function ajaxCall(soap, url){ // Post SOAP request. $.ajax({
I have a ajax function as below <script type=text/javascript> $(document).ready(function () { var timer,
I have an ajax call handled with jquery like this: var GetAppointmentDate = {'DateInput'
I have an object that I want to send with my jquery.ajax function but
I'm making an ajax POST to this url using jQuery like this : var
I have a button that performs an ajax post -- I want to disable
I am using JQuery and I have below code. $(#departure_city).change(function() { $.ajax( { type:'post',
I have a function like this that does an ajax call to grab some
I have a AJAX post method that gets xml data from server. But when

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.