I was wondering if there is any possibility through which one can reset the timeout of an AJAX request through an ‘external’ control. For example, let’s say I have the following:
jQuery.fn.worker = function worker() {
$.get('/home/GetData', function (data) {
// Manipulate retrieved data
});
setTimeout(worker, 30000);
};
Would it be possible to have, let’s say, a button through which I could reset the worker’s timeout?
Thank you in advance!
Assuming you make the timer available globally, you can use
clearTimeout(timer).