I have two AJAX deferreds which, when both succeed, should result in a success message. Otherwise, if either fails, the error message should show. Reduced code:
var reqs = $.map(['file', 'db'], function(mode) {
$.get(wspath(desyn.repo_id, 'revert', { mode: mode, path: path, version: ver }))
});
$.when(reqs[0], reqs[1]).then(
function() { alert('success'); },
function() { alert('error'); }
);
For debugging purposes, I force the first request to fail - on the server I'm throwing an internal 500 error. This is borne out in the network console. However, the success callback is executed nonetheless, not the fail callback.
As I understand it (and as described in the final example on the jQuery docs page), passing two functions to then() means the first is the success callback and the latter the fail callback. So what's up?