Return promise skipping Ajax call

Tags: ,



I have a function in a class like this that returns a promise for deleting an item:

function Delete(){
    // if(this.id == ""){
    //   return ?;
    // }
    return $.ajax({
       ... ajax details ...
    });
}

My question is, what do I return in order to ‘skip’ the ajax section which will validate to done so that I can do something like this (in another script):

$.when(Delete()).done(function(){
  ... code to execute after item is deleted ...
});

Answer

Both of these seem work.

return $.when();
return true;

Thanks to the comments.



Source: stackoverflow