JS timed call method succeeds and stops calling sample _javascript tips

Source: Internet
Author: User
Copy Code code as follows:

<pre name= "Code" class= "JavaScript" ><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, and if used with. NET, it will produce an error that cannot be invoked." </span></pre> so the following GetResult () JS method name to be changed to another name, so as not to create other ambiguity!
<pre></pre>
<pre name= "Code" class= "JavaScript" > </pre><pre name= "code" class= "JavaScript" ></pre>< Pre name= "code" class= "JavaScript" >//timed Refresh Flag
var refreshid= "";//Note defined as global variable
function Felsh () {
Alert ("Timed call method Start");
Refreshid=setinterval (getresult,1000);
}
The method being invoked

function GetResult () {
try{
var str=addfunctionname ()//unsuccessful return 1
if (str== "1") {
return str;
}
Clearinterval (Refreshid)//Clean Time service after successful
}catch (e) {
Alert (' Exception: ' +e.description '); or alert (' Exception: ' +this.print (e));/The advantage is that you can print the error.
}
Return "";
}
function Addfunctionname () {
return "1";
}</pre><br>
<br>
<pre></pre>
<pre name= "Code" class= "JavaScript" > </pre><br>
<pre></pre>

</pre>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.