I am using ajax and asp.net. iI have a javascript function which creates many other javascript functions with setTimeout. After asynchronous postback happenes, I want to disable all of these setTimeouted events. How can I do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you call
setTimeout(), store the timer ID so you can clear it. If you’re creating many timeouts, then an array is a good option for storing the IDs. For example:Then when you want to clear them:
As @Robert noted below,
clearTimeout()won’t throw an error if the timeout has already occurred, so there are no race/timing issues here.