Js periodically calls the method successfully and then stops calling the example

  • 2020-03-30 02:33:09
  • OfStack

 
<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  in .net If and .net If used together, it will cause an error that cannot be invoked. </span></pre> So the following getResult()js The name of the method should be changed to a different name so that there is no 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 that it is defined as a global variable
function felsh(){ 
//Alert (" regular method call begins ");
refreshid=setInterval(getResult,1000); 
} 
//Called method

function getResult(){ 
try{ 
var str=addFunctionName();//Returns 1 on failure
if(str=="1" ) { 
return str; 
} 
clearInterval(refreshid);//Clear the timing service on success
}catch(e){ 
alert(' Exception: '+e.description); // or alert(' Exception: '+this.print(e));// The advantage is that you can print them out  
} 
return ""; 
} 
function addFunctionName(){ 
return "1"; 
}</pre><br> 
<br> 
<pre></pre> 
<pre name="code" class="javascript"> </pre><br> 
<pre></pre> 

</pre> 

Related articles: