Perform a clear timer operation, unable to clear the js timer

now the scenario is as follows: an asynchronous ajxa1 (method 1) is executed in a for loop, and then a timer is turned on in the for loop (settimeout nested setinterval two timers), and ajxa2 is called in both timers (method 2). Now I need to clear the timer for the generated settimeout and setinterrval in the callback success or error method in method 1 (the timer will always call method 2 when method 1 executes without a callback). What I do now is to save the timer id under an array of objects at the end of the loop, and then clear it in the callback of method 1. Through console.log, we can make sure that two timer id, can be obtained in the callback and perform the clear operation, but I don"t know why the timer can"t be cleared.

Oct.25,2021

can I post the code


it is estimated to be the variable scope inconsistency problem of saving timer ID

Menu