hi everyone, I need help, I make a chat room n make function to call ajax every three second to refresh list of the chat, but don't work just once it work and didn't called every 3 second. here is my code:
thx for the help.Code:<body onload="loadChat(<? echo $_GET['idroom']; ?>)"> function loadChat(id) { getChat(id); setInterval("getChat("+id+")",5000); } function getChat(idroom) { if(XMLHttpRequestObject) { var obj2 = document.getElementById("FCKeditor1"); XMLHttpRequestObject.open("POST", "isi.php"); XMLHttpRequestObject.setRequestHeader('Content-Type','application /x-www-form-urlencoded'); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { if (XMLHttpRequestObject.responseText) { obj2.value = XMLHttpRequestObject.responseText; else alert ("error"); } } XMLHttpRequestObject.send(null); } }
regards
eko.
this:
should be placed in the onload event because it starts the function every 5 secondsCode:setInterval("getChat("+id+")",5000);
if you dont wanna replace the onload function use setTimeout() instead of setInterval() . ame syntax but setInterval runs the function every N seconds, and setTimeout runs the function after N seconds
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
www.amrosama.com | the unholy methods of javascriptCode:eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
thx for your reply, but I just realize my mistake, not the function setTimeout just a little mistake. thx for the help.
regards eko
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks