Why does jqXHR.done() return jqXHR object?

1.7k views Asked by At

Received jqXHR object from my $.post query contains done function. But I realized that this function returns just its jqXHR object:

$.post(query, function(a,b,jqXHR) {
  jqXHR === jqXHR.done() //true
});

How shoud I interpret that?

1

There are 1 answers

0
Dekel On BEST ANSWER

Since jquery's ajax call return a Promise, any of done(), fail(), always(), and then() functions will return the jqXHR object in order for the Promise to work correctly.

More information can be found here:
http://api.jquery.com/jQuery.ajax/#callback-functions