Whats wrong with how i set up the setInterval() function?
-
Im using AJAX to get some data and i would like to refresh the data but when i get one "friend_id" and then another, i get what i think are to intervals because one list loads on top of another over and over. function open_chat(friend_id){ var friend_id = friend_id; var hr = new XMLHttpRequest(); var refresh = null; if(refresh) clearInterval(refresh); refresh = setInterval(function(){ var url = "friends.php"; var vars = "friend_id="+friend_id; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readyState == 4 && hr.status == 200) { var return_data = hr.responseText; document.getElementById("table").in… = return_data; } } hr.send(vars); },1000); }
-
Answer:
You need to include the lower bound and upper bound for your interval... Good luck!
Hector at Yahoo! Answers Visit the source
Related Q & A:
- How can I cancel a Yahoo Alert that I set up earlier?Best solution by Yahoo! Answers
- How can I set up my computer to alert me when I get an incoming email?Best solution by Yahoo! Answers
- How do I set my e-mail to alert me when I get a new message?Best solution by Yahoo! Answers
- How do I set up an I.M. on Yahoo?Best solution by answers.yahoo.com
- How do I set up my set top box?Best solution by Server Fault
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.