jquery / jquery/api.jquery.com
Be more unambiguous about the return type jqXhr.then() as opposed to jqXhr.done() or jqXhr.always()
Open
Nobody has claimed this yet.
help wanted
- Dominant language
- HTML
- Stars
- 325
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
jqXhr.done() and jqXhr.always() methods return a jqXhr object while jqXhr.then() returns a promise, which is not that obvious at all.
For example, this code works:
var jqXhr1 = $.ajax({
url: "data.json",
method: "GET",
dataType: "json"
}).always(function () {
console.log("Always 1");
});
jqXhr1.abort();
But this doesn't:
var jqXhr2 = $.ajax({
url: "data.json",
method: "GET",
dataType: "json"
}).then(function () {
console.log("Then 2");
});
jqXhr2.abort(); // fails, cause it's a promise
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the API documentation entries for jqXhr.then(), jqXhr.done(), and jqXhr.always(), and compare how each return value is described. Use the issue's two examples to make the jqXhr-versus-promise distinction and the abort behavior unambiguous; done means the documentation clearly communicates these differences.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100