0

I'm trying to do this:

sendDetails(formData).done(checkErrors).done(nextForm);

Where sendDetails returns a JQuery.ajax(...) object

and checkErrors for now is

function checkErrors(data) {
    $.Deferred().reject();
}

I was under the assumption that this would prevent the call to nextForm, but it doesn't - what am I missing?

Using jQuery 1.11

Silver
  • 4,911
  • 3
  • 15
  • 16

2 Answers2

0

The documentation here at http://api.jquery.com/deferred.done/ says:

Since deferred.done() returns the deferred object, other methods of the deferred object can be chained to this one, including additional .done() methods.

If I understand your question, I think that answers your question. Hope this helps.

Vic F
  • 1,143
  • 1
  • 11
  • 26
0

jQuery deferred: cancel progress has the answer. Basically .done returns a deferred object, not a promise, so you can't cancel the subsequent call from the first call.

sendDetails(formData).then(checkErrors).done(nextForm); 

works as anticipated

Community
  • 1
  • 1
Silver
  • 4,911
  • 3
  • 15
  • 16