Home > Web Front-end > JS Tutorial > body text

JS implements scheduled tasks, requesting background setInterval timing and ajax requests every N seconds

一个新手
Release: 2017-10-16 09:57:57
Original
3239 people have browsed it

<span style="font-size: 16px"><strong><span style="color: #0000ff">DiGui = function<span style="color: #000000"> (param) {                
$.ajax({  
    success: <span style="color: #0000ff">function<span style="color: #000000"> (returnValue) {
        window.setInterval("fnSetMarkPoint()", 5000<span style="color: #000000">); 
    }
});<br/></span></span></span></span></span></strong></span>
Copy after login

After calling the DiGui() method

Problem: Create a setInterval every 0.1 seconds in a tree shape Create setInterval in a loop until the page crashes

Solution: Ensure that the setInterval object is only created once

Implementation plan: Define a Boolean variable for judgment var status= true;


 status =  = .: = .setInterval("()", 5000
Copy after login

The above is the detailed content of JS implements scheduled tasks, requesting background setInterval timing and ajax requests every N seconds. For more information, please follow other related articles on the PHP Chinese website!

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