Auto refresh comments in Wordpress

Discussion in 'Programming' started by Pintoria, Jul 10, 2009.

  1. #1
    I want to create a real time comment system on Wordpress. I use the following code:

    <script type="text/javascript">
    function Ajax(){
    var xmlHttp;
    	try{	
    		xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
    	}catch (e){
    		try{
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
    		}catch (e){
    		    try{
    				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    			}catch (e){
    				alert("No AJAX!?");
    				return false;
    			}
    		}
    	}
    	xmlHttp.onreadystatechange=function(){
    		document.getElementById('ReloadThis').innerHTML=xmlHttp.responseText;
    		setTimeout('Ajax()',2000);
    	}
    	xmlHttp.open("GET","http://www.gprsmms.com/wp-content/themes/default/comments.php",true);
    	xmlHttp.send(null); 
    }
    window.onload=function(){
    	setTimeout('Ajax()',2000);
    }
    </script>
    Code (markup):
    http://www.gprsmms.com/wp-content/themes/default/comments.php is the path to comments file and #ReloadThis is the ID of the DIV tag.

    The page refreshes after some x seconds.

    On the site, it shows: Please do not load this page directly.

    How ca I fix this?

    Thank you in advance!
     
    Pintoria, Jul 10, 2009 IP