I want to add a catch
method to JQuery\'s promise
object so I don\'t have to type the following every time:
.then(null,function(dat
You can create your custom then
$.Deferred().prototype.customthen = function(){
$.Deferred().prototype.then.call(this, null, ,function(data){
// handle error
return $.Deferred().resolve().promise();
})
}
You have added a new function named customthen to the prototype. So, this new function is available in all instances.
Now, you can use it as follows
.customthen();