| |

VerySource

 Forgot password?
 Register
Search
View: 13|Reply: 5

Why is setTimeout not executed only once?

[Copy link]

1

Threads

6

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 China

Post time: 2020-3-1 17:00:02
| Show all posts |Read mode
function getMessage ()
{
window.alert ("ok!");
var timer = setTimeout ("fLoadXml ('xml.xml', fShowXml);", 1000)
var timer = setInterval ("fLoadXml ('xml.xml', fShowXml);", 2000)
}
</ script>

I use getMessage () to execute fLoadXml ('xml.xml', fShowXml); both setTimeout and setInterval are executed only once and not executed. Why is this?
Wait online, thank you !!
Reply

Use magic Report

0

Threads

5

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 China

Post time: 2020-5-11 12:15:01
| Show all posts
The first parameter of setTimeout should be the function body (getMessage) and not what fLoadXml
Reply

Use magic Report

0

Threads

4

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-5-11 23:00:02
| Show all posts
function getMessage ()
{
fLoadXml ("xml.xml", fShowXml);
}
var timer = setInterval ("getMessage", 2000)
</ script>
Reply

Use magic Report

1

Threads

6

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 China

 Author| Post time: 2020-5-11 23:15:01
| Show all posts
What about fLoadXml?
Reply

Use magic Report

0

Threads

4

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-5-12 11:00:01
| Show all posts
function getMessage ()
{
fLoadXml ("xml.xml", fShowXml);
}
var timer = setInterval ("getMessage ()", 2000)
</ script>
Reply

Use magic Report

1

Threads

6

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 China

 Author| Post time: 2020-5-13 20:30:02
| Show all posts
Thank you very much, it has been solved !!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list