Reputation: 24061
My currentReq var is set to a call back method:
this.currentReq = cb.apply(this,args);
Later I may wish to abort the method if it is an ajax call.
I know I can use:
this.currentReq.abort();
But what if the currentReq is not an ajax call? How can I test for this and only abort if its an ajax call? I get an error when I try and abort on a standard deferred.
Upvotes: 0
Views: 89
Reputation: 570
If the error is to an undefined method the you should be able to test if the function itself exists
if(typeof this.currentReq.abort === 'function') {
this.currentReq.abort();
}
Upvotes: 2
Reputation: 17661
You may first test to see if the abort
method exists:
if (typeof(this.currentReq.abort) == "function") {
this.currentReq.abort();
}
Upvotes: 3