chriscloyd Posted June 7, 2007 Share Posted June 7, 2007 i have this code and its supposed to refresh every 20 milliseconds but it doesn't can someone help me i got it from the tutorial <script type="text/javascript"> function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('There was a problem creating the XMLHttpRequest object'); } return req; } // Make the XMLHttpRequest object var http = createRequestObject(); function sendRequest(act) { // Open PHP script for requests http.open('get', 'getchat.php?act='+act); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4 && http.status == 200){ // Text returned FROM PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById("countPosts").innerHTML = response; setTimeout(countPosts,1); } } } sendRequest('countPosts'); </script> Link to comment https://forums.phpfreaks.com/topic/54533-ajax-refresh/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.