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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:49:23+00:00 2026-06-12T01:49:23+00:00

I need is to add an unknown number (known only at runtime) of .pipe()

  • 0

I need is to add an unknown number (known only at runtime) of .pipe() calls to the functions being monitored by jQuery’s .when(). These calls will be based off of ajax calls made as a result of another asynchronous operation. Please see the code below for a more clear explanation:

$.when(
    $.ajax({ 
        async: true,        
        success: function (data, textStatus, jqXhr) {
            console.log('Level 1')

            for(var i = 0; i < data.length; i++)
                jqXhr.pipe(
                    $.ajax({  
                        data: data[i],                                                              
                        async: true,        
                        success: function (data, textStatus, jqXhr) {
                            console.log('Level 2');
                        },       
                    })
                );
        },       
    }),
    $.ajax({
        async: true,        
        success: function (data, textStatus, jqXhr) {
            console.log('Level 3');
        },       
    })
).done(function(){ console.log('All done!'); });

Basically Level 1 and Level 3 need to execute in parallel. The Level 2s are all based off of the result of Level 1. And Level 1, all the Level 2s and Level 3 need to execute before All done.

Using the code above doesn’t work, as the call to .pipe() does not affect what .when() is monitoring.

Is it possible to do what I want with jQuery’s Deferred framework?

Thanks for any help.

Note: Earlier, I asked a very similar question, but I’ve realized the situation is significantly more complicated than what I illustrated there and I didn’t want to cause confusion with the existing answers.

Original question

  • 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-12T01:49:24+00:00Added an answer on June 12, 2026 at 1:49 am

    It’s not that much more complicated. If you want to execute all level 2 calls in parallel, just call $.when inside the .pipe callback and return that deferred object:

    $.when(
        $.ajax({        
            // ...      
        }).pipe(function(data) {
            // concise way to make the Ajax calls for each value
            var deferreds = $.map(data, function(value) {
                return $.ajax({data: value, /*...*/});
            });
            return $.when.apply($, deferreds);
        }),
        $.ajax({        
            // ...       
        })
    ).done(function(){ console.log('All done!'); });
    

    If you want to execute them sequentially, use .pipe again:

    $.when(
        $.ajax({        
            // ...      
        }).pipe(function(data) {
            // A "dummy" resolved deferred object 
            var deferred = (new $.Deferred()).resolve();
            $.each(data, function(value) {
                deferred = deferred.pipe(function() {
                    return $.ajax({data: value, /*...*/});
                });
            });
            return deferred;
        }),
        $.ajax({        
            // ...       
        })
    ).done(function(){ console.log('All done!'); });
    

    I have to say though that you should keep the number of Ajax calls to a minimum.

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

Sidebar

Related Questions

I'm trying to set up unknown number of plupload instances on page. I need
I need to be able to add an unkown number of where clauses to
I need to store an unknown number of groups. Each group has an unknown
I need to store an retrieve a vector of an unknown number of objects
I need add Auto complete on apex Tabular Form. there is a column as
I need add a new user group for mediawiki. The new group has more
I can't access a element with its href. Like this example, i need add
Hї! I have wrote test for my application. I need add item to database
Need to add two same name .csproj class libraries in my solution.Have two project
need to add a 2nd css stylesheet to a page. do i add a

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.