function checkStatusOfRequest(requestId) {
var filePath = "";
$.ajax({
type: "POST",
url: "<?php echo TESTMINE_APP_URL; ?>/ajax/check-export-status",
data: 'requestId=' + requestId,
dataType: "json",
success: function (data) {
if (data.exportType == 'csv') {
filePath = $("#csvFilePath").val();
} else if (data.exportType == 'pdf') {
filePath = $("#pdfFilePath").val();
}
if (data.status == 'downloadReady') {
fileName = data.fileName;
$("#statusDisplay").css("visibility", "hidden");
$("#download").css("visibility", "visible");
$('#requestId').val(requestId);
setTimeout(checkStatusOfRequest, 9000);
}
}
});
Asked
Active
Viewed 185 times
-3

Chaya
- 95
- 3
- 12
-
Format your code first – Sabari Dec 10 '13 at 09:16
-
Don't just paste code please – Fabien Sa Dec 10 '13 at 09:18
3 Answers
1
//keep the returned timeoutID
var timeoutID = setTimeout(checkStatusOfRequest, 9000);
....
//clear the timeoutID
clearTimeout(timeoutID );

Andrew
- 5,290
- 1
- 19
- 22
-
According to status of checkStatusOfRequest function clearTimeout of checkStatusOfRequest – Chaya Dec 10 '13 at 09:21
0
You should set the timer to a variable first
var statusTimer = setTimeout(checkStatusOfRequest, 9000);
To clear timer call
clearTimeout(statusTimer);

Sabari
- 6,205
- 1
- 27
- 36
0
setTimeout()
calls a function or evaluates an expression after a specified number of milliseconds
var myVar = setTimeout(function(){alert("Hi")},1000);
The ID value returned by setTimeout()
is used as the parameter for the clearTimeout()
method.
clearTimeout(myVar);

Shamse Alam
- 1,285
- 10
- 21