Home > Web Front-end > JS Tutorial > Example of stopping the call after js scheduled calling method is successful_javascript skills

Example of stopping the call after js scheduled calling method is successful_javascript skills

WBOY
Release: 2016-05-16 16:52:58
Original
1184 people have browsed it
Copy code The code is as follows:

 <pre name="code" class="javascript"> <span style="color: rgb(58, 62, 67); font-family: 'Segoe UI Semibold', 'Segoe UI', 'Lucida Grande ', Verdana, Arial, Helvetica, sans-serif; font-size: 22px; line-height: 27px; ">GetResult is also available in .net. If used together with .net, it will cause an error that it cannot be called. </span>
Therefore, the name of the getResult() js method below needs to be changed to another name so as not to cause other ambiguities!
 
 
 
//Scheduled refresh flag<br>var refreshid="";//Note that it is defined as a global variable<br>function felsh(){ <br>//alert("Timed calling method starts"); <br>refreshid=setInterval(getResult,1000); <br>} <br>//Called method<br><br>function getResult(){ <br>try{ <br>var str=addFunctionName();//return 1 if unsuccessful <br>if(str=="1"){ <br>return str; <br>} <br>clearInterval(refreshid) ;//Clear the timing service after success<br>}catch(e){ <br>alert('Exception:' e.description); // or alert('Exception:' this.print(e));// The advantage is that you can print out typing errors <br>} <br>return ""; <br>} <br>function addFunctionName(){ <br>return "1"; <br>}
< br>


 
 


 


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template