Auto refresh comments in Wordpress
I want to create a real time comment system on Wordpress. I use the following code:
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>http://www.gprsmms.com/wp-content/th…t/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!
Original post by Pintoria