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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:58:48+00:00 2026-06-18T03:58:48+00:00

I have an object that uses jQuery’s Deferred to create my own promise that

  • 0

I have an object that uses jQuery’s Deferred to create my own promise that I resolve after a timeout. I then chain an ajax call, and return the promise.

var Obj = function() {
  var _obj = new $.Deferred();

  setTimeout(function() {
      _obj.resolve("Resolve One!");
  }, 2000);

  return _obj.promise();
}

new Obj()
.done(function(message) {
  document.write(message);
  return $.get("http://www.jsonip.com/");
})
.done(function(response) {
  document.write(response);
})

I’d expect message to have “Resolve One!” and response to have the response from the ajax call

Result expected:

Resolve One!{"ip":"256.256.0.0","about":"/about"}

What I get instead:

Resolve One!Resolve One!

Since I’m returning $.get(), which is a promise, I’d expect the old promise to be overridden with the one from jQuery. What should I be doing instead, to get the the web page contents into response`?

jsfiddle: http://jsfiddle.net/7zUKg/

  • 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-18T03:58:49+00:00Added an answer on June 18, 2026 at 3:58 am

    .done only adds the handler. You want .then, which also allows you to return a new promise: http://jsfiddle.net/7zUKg/1/.

    new Obj()
    .then(function(message) {
      document.write(message);
      return $.get("http://www.jsonip.com/");
    })
    .done(function(response) {
      document.write(response);
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that uses jQuery to dynamically create an silverlight object.
I have a web application that uses the CDO Message object to email reports.
I have a flex 3 app that uses netstream and a video object to
I currently have a Javascript function that uses a string to reference an object
I have created an app in C# .Net 2.0 that uses the AxShockwaveFlash object
I have a PHP stuff that uses call_user_func to create element/objects to a certain
I have a very simple test page that uses XHR requests with jQuery's $.getJSON
I have some web application that uses jQuery to send AJAX requests to server.
I have simple AJAX function that uses jQuery to return an array of 300
I have an ASP.NET MVC application that uses jQuery 1.3.2. On several of the

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.