javascript
2013-12-10 4 views -3 likes 
-3
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); 


      } 

     } 
    }); 
+0

형식 코드 첫 – Sabari

+0

은 checkStatusOfRequest의 checkStatusOfRequest 기능 사항 clearTimeout의 상태에 따라 코드 바랍니다 –

답변

1
//keep the returned timeoutID 
var timeoutID = setTimeout(checkStatusOfRequest, 9000); 
.... 
//clear the timeoutID 
clearTimeout(timeoutID); 
+0

붙여 넣기하지 마십시오 – Chaya

0

당신은

clearTimeout(statusTimer); 
0

setTimeout()는 함수를 호출 또는 밀리 초

을 지정된 수의 후 식을 계산 타이머 호출을 지우려면 변수 첫번째

var statusTimer = setTimeout(checkStatusOfRequest, 9000); 

에 타이머를 설정해야합니다

var myVar = setTimeout(function(){alert("Hi")},1000); 

에 의해 반환 된 ID 값은 clearTimeout() 메서드의 매개 변수로 사용됩니다.

clearTimeout(myVar); 
관련 문제