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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:27:29+00:00 2026-05-25T03:27:29+00:00

Ok, I am probably missing something obvious, and although I’ve tried to find a

  • 0

Ok, I am probably missing something obvious, and although I’ve tried to find a similar example, I can’t find one quite like what i’m wanting to do. I’m needing a series of ajax calls to run in a particular order. I’m using the following code to finalize a transaction:

showStandbyDialog();
    $.when(function(){console.log('Paying Charges due before transaction');})
        .always( this.applyCredit(parseFloat($(this.currentChargesTarget).html())) ) // Pay charges due before transaction
        .always(function(){console.log('Applying renewals');})
        .always( this.applyRenewals() ) // Apply Renewals
        .always(function(){console.log('Paying renewal charges');})
        .always( this.applyCredit(this.renewCart.length * this.renewCost) ) // Pay renewal charges
        .always(function(){console.log('Applying checkouts');})
        .always( this.applyCheckOut() ) // Apply checkouts
        .always(function(){console.log('Paying checkout charges');})
        .always( this.applyCredit(this.cart.length * this.checkOutCost) ) // Pay checkout charges
        .always(function(){console.log('Applying card replacement');})
        .always( this.applyCardReplacement() ) // Apply card replacement
        .always(function(){console.log('Paying leftover charges');})
        .always( this.applyCredit(this.cardCost) ) // Pay leftover charges
        .always(function(){console.log('Finalizing Transaction');})
        .always( function(){ updateCharges(); bfwd.Patron.Transaction.reset(); hideStandbyDialog(); } ); // Reset Transaction and clear standby dialog

Now I have tried, .done, .then, and just about .anything() but the console.log() code in the handle function of this.applyCredit() ALWAYS logs after the console.log(‘Finalizing Transaction’). Every this.function() call returns a jquery deferred method in case you were wondering.

  • 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-25T03:27:30+00:00Added an answer on May 25, 2026 at 3:27 am

    I completely remade my jsFiddle here: http://jsfiddle.net/JohnMunsch/nxPn3/

    About 10 times 🙂

    .always() was returning the same Deferred object (or Promise) that had completed in the first .when() to all of the other .always() functions. So they went off in rapid fire succession. It looked roughly like this.

    Step 1: log.
    Step 2: kick off ajax call, log, kick off ajax call, log, kick off ajax call, log, etc. etc.
    

    I didn’t really see it until I put timers in each of my “ajax call” functions to make them delay a while. Then I kept having the problem of, how do I do this without nesting each next step in the previous step’s .done() function?

    My solution to that one may not be the most graceful, but it worked. I created a complete set of Deferred objects up front and I use them to prevent each successive step from starting until the previous step is either marked resolved or rejected.

    Here’s a excerpt from that:

    console.log('Paying Charges due before transaction');
    var step1 = applyCredit("parseFloat($(this.currentChargesTarget).html())");
    var step2 = new $.Deferred();
    var step3 = new $.Deferred();
    
    $.when(step1).done(function(){
        console.log('Applying renewals');
        $.when(applyRenewals()).done(function () {
            step2.resolve();
        });
    }).fail(function () { step2.reject() });
    
    $.when(step2).done(function(){
        console.log('Paying renewal charges');
        $.when(applyCredit("some subcalc")).done(function () {
            step3.resolve();
        });
    }).fail(function () { step3.reject() });
    

    Now when you run the jsFiddle, each function call marches along in a perfect row. The second doesn’t start until the first has finished and the third can’t begin until the second is done…

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

Sidebar

Related Questions

Probably I'm just missing something obvious, but I can't get the image in my
I'm probably missing something simple here, but I can't find the answer elsewhere. I
I am probably missing something obvious but anyway: When you import a package like
I'm probably missing something obvious, but I can't see any difference between std::condition_variable and
Complete beginner so I'm probably missing something obvious but... I can't seem to combine
I'm probably missing something obvious here but here's what I'm trying to do. From
I am probably missing something obvious, but I am getting a 'Object reference not
Probably missing something completely obvious here, but here goes. I'm starting out with Spring
I'm probably missing something very obvious here. I have files with the extension .st
OK, I'm probably missing something obvious here, but my searches aren't turning up anything

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.