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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:09:26+00:00 2026-05-19T22:09:26+00:00

Let’s say I use $.get to receive an array of user IDs. Let us

  • 0

Let’s say I use $.get to receive an array of user IDs.
Let us then presume that I want to go through all those user IDs (example: [13, 14, 15, 23, 34, 56]) and retrieve certain information on each, then populate a textfield based on the results, and move on to the next one.

$.each(array_of_users, function(i, id) {
    $.get("/somefunction", {id}, function(data){
         appendToField(data);
    }, "json");
});

How would I make it so that these loops don’t all happen at once and then wait for the result together asynchronously, as they do now, but one by one? That is, I want to stop the loop from going onto the next element until the ajax requests says it’s fine to do so.

What is the best way to approach this without using delays or timeouts, but actual responses from the function doing the processing?

Cheers

Edit:
The stylish representation of a “command-prompt” look is important to me, which is why I would like the textarea to receive messages one by one as the entries are processed. I am aware I could do this via PHP much easier and without the hassle or potential JS breaks, but I would like to do it stylishly via JS to simulate this “console” look, as in:

10:01:33: User 13 processed: Changed expiry date to 13.02.2011.
10:01:34: User 16 not processed: Target immune to system changes..
10:01:34: User 17 not processed: Target immune to system changes..
10:01:35: User 23 processed: Changed expiry date to 19.02.2011.
etc..

Edit2:

I just found this brilliant little plugin which lets me do exactly what I want. However, I cannot find the means to stop the queue once it’s been started. This is now a new issue. Any ideas, anyone? Reloading the page works, naturally, but I would like it to freeze in place as soon as I hit the Stop button so that the user can simply copy the entire report right out of the textfield.

  • 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-19T22:09:26+00:00Added an answer on May 19, 2026 at 10:09 pm

    Basically, use the first .get() to retrieve the list of values (array_of_users). Using this list, pass them off to a “worker” function that takes the first element, works with it, then sends the remaining elements off to do the same. Keep going until there are no more entries to process. (think of it like a FIFO Queue)

    $.get('/loadfunction',{},function(data){
      getinfo(data.array_of_users);
    },'json');
    
    function getInfo(array_of_users){
      if (array_of_users.length == 0)
        return;
    
      $.get('/somefunction',{array_of_users[0]},function(data){
        // handle the result of this id
        appendToField(data);
    
        // move on through the list, dropping the first element
        getInfo(array_of_users.slice(1));
      });
    }
    

    EDIT: used variables / GET paths similar to what you mentioned in your initial question.

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

Sidebar

Related Questions

Let's say that I'm currently designing an application where I will need to use
Let's say I have a drive such as C:\ , and I want to
Let's say I'm writing a PHP (>= 5.0) class that's meant to be a
Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say that I have an arbitrary string like `A man + a plan
Let's say I have two files.. I want to compare them side-by-side and see
Let's say I have a table that looks something like this: ------------------------------- id|column2|column3 |column4
Let's say i have an android device that has some extra buttons on it,
Let's say that I am using a 3rd party utility tool and I can't
Let's say I have a javascript array with a bunch of elements (anywhere from

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.