The cancel() method cancels the current job, if it has not already been canceled. If the job is successfully canceled, the job SID is set to null.
Calling this method raises the jobCanceled and jobStatusChanged events.
status = cancel( onSuccess , onFailure )
|
onSuccess |
Function |
(Optional) Function to be called on successful cancellation. |
|
onFailure |
Function |
(Optional) Function to be called on unsuccessful cancellation. |
|
Boolean |
Cancel request status: Undefined = Job canceled. False = Job already canceled or could not be canceled. |
Error: "Cannot call the job endpoint if we dont have an sid yet"
var context = this.getContext();
var search = context.get('search');
if (search.job.cancel(function() {
console.log('Handle successful job cancellation.');
}, function() {
console.log('Handle failure to cancel job.');
}) == false)
console.log('job already canceled or could not be canceled.');