jquery / jquery/api.jquery.com

Be more unambiguous about the return type jqXhr.then() as opposed to jqXhr.done() or jqXhr.always()

Open
#442 3 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.