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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:22:38+00:00 2026-05-30T20:22:38+00:00

RESOLVED I’m having an issue with $.Deferred in jQuery 1.7.1. I think the behaviour

  • 0

RESOLVED

I’m having an issue with $.Deferred in jQuery 1.7.1. I think the behaviour of the returning values from when/then/fail etc is different to what I think it should be.

This is what I’m trying to do:

  1. Call $.when(setInstall(true)).then('do something'); (this works, it waits for the ajax request)
  2. –> Call this.inInstallableRegion() which runs an ajax request.
  3. —> When the AJAX request is successful, I want to resolve or reject inInstallableRegion‘s $df depending on the result of the AJAX request.
  4. —-> this.inInstallableRegion has detected there is an error, so it rejects $df‘s promise (this works) and I want it to return that to setInstall. I’m assuming that the return value of this.inInstallableRegion‘s $.done() is returned as the result of this.inInstallableRegion (i.e. rejected in this case).

For some reason it rejects $df, but when I go to setInstall, it runs the $.done function, instead of the $.fail one :.. am I missing something?

Sorry, can’t really do a jsfiddle for this :\ can’t think of a way to simplify it down more… my brain is totally fried 😐

These are the two functions:

    this.setInstall = function (status) {
        $df1 = new $.Deferred();
        if (status === true) {
            var self = this;
            return $.when(this.inInstallableRegion()).done(function (json) {
                self.setInstallDetail(json);
                self.setDispatchCompany();
                $df1.resolve();
                return $df1.promise();
            }).fail(function (json) { 
                self.notifyNoInstall(json.error); 
                self.setInstall(false);
                self.setDispatchCompany();
                $df1.reject();
                return $df1.promise();
            });
        } else {
            this.setInstallDetail({
                install: 0,
                ref_id: 0,
                retail_price: 0
            });
        }
        this.setDispatchCompany();
        $df1.resolve();
        return $df1.promise();
    };

////////////////////////////////////////

this.inInstallableRegion = function () {

    $df = new $.Deferred();

    var params = {
        dataType: 'json',
        data: $.param({
            'zip': this.order.delivery.zip
        }),
        action: 'getinstaller',
        cache: true
    };

    return $.when(this.sendData(params, 'installerCache', true)).done(function (json) {
        if (json.error) {
            $df.reject();
            return $df.promise();
        } else {
            $df.resolve();
            return $df.promise();
        }
    });

};
  • 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-30T20:22:39+00:00Added an answer on May 30, 2026 at 8:22 pm

    I figured it out.

    In order for setInstall to wait for inInstallableRegion to finish, inIntsallableRegion had to return something. It wouldn’t work to just return the ajax request, because it’d return just when that was completed or not. It wouldn’t return whether or not I wanted to accept or reject based on the result of the ajax request.

    So I just made it return its own deferred object of when the ajax ran AND when the result was processed. I did this in inInstallableRegion

    var self = this;
    return $.Deferred(function(dfd) {
      self.sendData(params, 'installerCache', true).then(function(json) {
        if(json.error) {
          dfd.reject();
        } else {
          dfd.resolve();
        }
        return dfd.promise();
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: R cannot be resolved - Android error I am having a issue
RESOLVED From the developer: the problem was that a previous version of the code
I resolved this issue myself. It turns out that the activation framework requires some
I recently resolved an issue my VB6 application had when saving large binary objects
I've got a pretty minor problem that I think can be resolved by re-thinking
RESOLVED: CSS Animation/Scale issue in Chrome/Webkit I asked this question previously, but I'm not
Update: This issue has been resolved. I was trying to authenticate various admin accounts
Edit 4: The main issue has been resolved - turned out the problem was
Related to a previous issue that I thought was resolved and actually isn't... My
A common issue for WCF appears to be how the hostname is resolved within

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.