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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:41:41+00:00 2026-06-02T15:41:41+00:00

How can I propagate all events on one JQuery.Deferred() object to another ? Is

  • 0

How can I propagate all events on one JQuery.Deferred() object to another ?

Is there a better / simpler / shorter way then handling both .fail and .then .done by calling the other objects .rejectWith and .resolveWith ?
I am assuming that I don’t have to handle .done .then as it will be called when I call Reject or resolve.

I suspect that maybe this can be done using .pipe but I am not sure how.

UPDATE:

Note: I also I fixed some of the text above per @Frédéric Hamidi’s comment.

What I am trying to achieve was the following:

I had a API that was making ajax calls to the server,
they would return the ajax object (which is a $.Deferred itself).

At some point I needed to handle a situation where I had not net work available (This is for a phonegap application running on a mobile device).

What I wanted to do was that in case of no network connectivity I would display a dialog prompting the user to fix the network issue and hit “retry”.

But in this scenario I would not call the $.ajax until the user hits retry so I did not have a $.Defferred object to return the the function that called on the API to begin with.

so I ended up understanding that I could just create a new $.Defferred and return it and on the callback for the retry button call the $.ajax itself setting it to “relay”/propagate the defferred events to the one I just returned by holing it as part of a closure.

But I was not sure of the way to do it. My mixup with the the .pipe method is because its description says its a:

Utility method to filter and/or chain Deferreds.

I hoep this makes my Question more clear.

  • 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-02T15:41:46+00:00Added an answer on June 2, 2026 at 3:41 pm

    If I understand correctly, you just want a Deferred to resolve/reject and notify with the exact same value as your ajax request? If so, assuming your Deferred object is called defer, the following code will do the trick:

    $.ajax( ... ).done( defer.resolve ).fail( defer.reject ).progress( defer.notify );
    

    It works because defer.resolve, defer.reject and defer.notify are lexically bound: the context (this) and values (arguments) are passed properly so you just effectively forwarded the state of the ajax promise into the new deferred.

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

Sidebar

Related Questions

Is there any way to centrally manage mercurial settings for all users of a
Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
My absolutely positioned canvas elements are blocking all the mouse events so that nothing
I need to proxy all the different event streams through one subject. I came
I know it's not possible to bind to all DOM events and I know
I'm wondering if there is an event that can be handled or a method
I am trying to propagate to my UI the GatewayConnectionFailedException as you can see.
can anyone help me in trying to check whether JavaScript is enabled in client
Can 2 or more equations defining a function in Haskell share the same where
can I make my own headers in HTTP request ? e.g. This is normal

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.