Skip to content
Advertisement

Return promise skipping Ajax call

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 ...
});

Advertisement

Answer

Both of these seem work.

return $.when();
return true;

Thanks to the comments.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement