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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:53:16+00:00 2026-06-07T12:53:16+00:00

I use callbacks all the time when using 3rd part libraries such as jquery,

  • 0

I use callbacks all the time when using 3rd part libraries such as jquery, however I’ve run into an issue where I need to set up my own call back. Take for instance my current code:

// Get All Rates
function getAllRates() {
    $('#shiplist tr.mainRow').each(function() {

        var curid = $(this).attr("id");
        var cursplit = curid.split("_");
        var shipid = cursplit[1];

        getRate(shipid);

    });

}

This iterates through all the table rows that have class “mainRow”, and each main row has the id of “shipment_#####” so for each row it splits by the _ to get the actual ship id, which it then uses to calla “getRate” function which sends an ajax call to the server using UPS or USPS api’s to get the rate for the given shipment.

This works fine for UPS all rows start loading at once and return their rates independently. The problem is now with Stamps.com, they use an authenticated soap conversation so an authenticator string needs to be received from the first call and used in the next call and so on.

So basically I need to modify the above function to execute the “getRate()” function and wait for it to complete before executing the next iteration.

Anyone know how I can do this with out a lot of fuss?

EDIT – Clearification on the question being asked:

I want to take the following function:

getRate(shipid);

and access it like so:

getRate(shipid, function(shipList) { _Function_data_here_ });

When I define the getRate function, how do I define it so that it has that callback ability? how does that work?

  • 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-07T12:53:18+00:00Added an answer on June 7, 2026 at 12:53 pm

    I would suggest you extract all the IDs at once and pass them to your function. That way, you can easily process the first on individually and the rest afterwards. With deferred objects, this is really easy.

    For example:

    function extractAllIds(callback) {
    
        var ids = $('#shiplist tr.mainRow').map(function() {
            return this.id.split('_')[1];
        }).get();
    
        callback(ids);
    }
    
    function getRates(ids) {
        var first = ids.shift();
    
        $.ajax({data: first, ...}).done(function(response) {
            // extract the authenticator string
            for(var i = ids.length; i--; ) {
                $.ajax({data: ids[i], ...});
            }
        });
    }
    
    extractAllIds(getRates);
    

    In any way, you cannot make $.each wait for response of Ajax calls.

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

Sidebar

Related Questions

I've run into quite an awkward predicament in a project at work. We need
In my Android application I use TTS and Voice Recognition. Despite using all the
I started coding in C# and have never had the opportunity to use callbacks
I've been making use of callbacks to reduce coupling between some C++ classes. To
I need to use a class callback method on an array inside another method
I am trying to use the return value(response) from the callback outside the jQuery.post
In Flash Professional CS4, I get migration issue warnings when I use mouse/keyboard input
My application creates a thread and that runs in the background all the time.
I need to catch the content of href using regex. For example, when I
I don't use javascript much so I am not that familiar with callbacks and

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.