Skip to content

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

Open
@Infeligo

Description

@Infeligo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions