我使用window.setInterval
方法来轮询进度状态。但是需要在完成时禁用此计时器。如何禁用定时器?
window.setInterval(function(){$.ajax({
type: 'GET',
url: 'imports',
success: function(response){
console.log(response);
if(response['status'] != 'ok'){
return;
}
$('.bar').css('width', response['progress'] + '%');
if(response['step'] == 'completed') location.reload();
}}, 'json');}, 1000);