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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:39:07+00:00 2026-05-23T08:39:07+00:00

How do I use a deferred with jQuery’s $.post ? I tried: var myFunc

  • 0

How do I use a deferred with jQuery’s $.post? I tried:

var myFunc = function(data, textStatus, jqXHR) {
    console.log(data);
};
var post = $.post("/url/", someData);
$.when(post).done(myFunc);

The usual

$.post("/url/", someData, function(data) { myFunc(data) });

works fine (after changing the myFunc signature).

$.when... doesn’t work, and no errors show me failures. What exactly is the .done() function passing into myFunc?

  • 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-23T08:39:07+00:00Added an answer on May 23, 2026 at 8:39 am

    The jQuery ajax functions return a jqXHR which is itself a deferred object (it implements the Promise interface). So no need for $.when().

    There is also no need to use a named function expression for myFunc, a normal function declaration is fine.

    function func1(data, textStatus, jqXHR) {
        console.log('success', data);
    }
    
    function func2(jqXHR, textStatus) {
        console.log('done', textStatus);
    }
    
    $.post('/url/', someData).success(func1).done(func2);
    

    Demo: http://jsfiddle.net/mattball/ng7zT/


    What exactly is the .done() function passing into myFunc?

    This is documented at the jqXHR link above, and also at $.post.

    The success callback function is passed the returned data, which will be an XML root element or a text string depending on the MIME type of the response. It is also passed the text status of the response.

    As of jQuery 1.5, the success callback function is also passed a "jqXHR" object (in jQuery 1.4, it was passed the XMLHttpRequest object).

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

Sidebar

Related Questions

I'm starting to use jQuery Deferred objects a bit more and I run into
I am having trouble learning to use the new jQuery Deferred. The does an
My question is: can we use dojo.xhrPost to post some Json data? More detail:
I'm trying to use the jQuery when function, in order to wait until an
I'm confused about how to use jQuery's Deferred object, and the examples I've seen
If you do not plan to use lazy loading, should deferred loading be explicity
Let's create a simple Deferred object: defer = $.Deferred( function ( defer ) {
I'm trying to implement the folowing scenario, using JQuery deferred, without much luck. What
If I plan to use data caching do I have to worry about conflicts
I'm trying to use google.appengine.ext.deferred to run a Task. I am passing a method

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.