I have a following method
mute: function (action) {
var deferred = $q.defer();
function muteRec() {
return jQuery.muteRec({
user: name,
action: action || 'mute',
ajaxSettings: {
suppressWarnings: true
}
});
}
if (jQuery.muteRec) {
deferred.resolve(muteRec());
} else {
this.loadCCRecordingScript()
.then(function () {
deferred.resolve(muteRec());
})
.catch(function () {
$rootScope.recordingNotavailable = true;
deferred.reject();
});
}
return deferred.promise;
}
I am new to jquery , What i wants that Instead of resolving the promise with another promise, I have to use success and error callbacks of jquery in muteRec and resolve or reject the promise in there.