작업 완료 여부를 확인해야하는 javascript 함수가 있습니다. 작업이 완료되면 서버의 파일에 완료 레코드가 있습니다. 파일에서 완료 레코드를 얻을 때까지 약간의 지연 (잠재적으로 증가하는)을 가진 서버에 대한 재귀 호출을 수행하는 함수입니다. 아래 코드는 웹 콘솔에서 [20 : 06 : 21.202] [20 : 06 : 21.563] [012 : 20 : 06 : 21.990] 예를 들어 초과하는 간격으로 서버를 과도하게 호출합니다. 그러나 작업이 변수 waittime 값이 max_waittime과 같아졌습니다. 테스트 케이스의 전체 출력이 예상대로이지만 기능에 문제가 있습니다. 내가 틀렸어?작업 완료 확인
function check_status(time,div_id,filename) {
var status =0;
var waittime=time;
var max_waittime=11000000;
if (waittime < max_waittime){waittime=waittime+1000000; }
$.ajax({
type: "GET",
async: false,
url: "code_on_server_checking_file.php",
data: "f="+filename,
dataType: "text",
success: function(content) {
if (content) {
// stuff related to output of the result
....
return status=1;
}
else {return status=0;}
}
});
if (status == 0 && waittime < 20000000){
setTimeout(check_status(waittime,div_id,filename),waittime);
}
else {alert('check_status passed!'+status+'|'+waittime);}
}
'async' 호출에 대한 좋은 지적. 나는 그것을 놓쳤다. –