0

I am new to ajax, and i am working on a class project.What I am trying to do/achieve is, to let that particular div to auto refresh. I know that there is alot of tutorials out there but most of it are using Jquery which i am not... So im not really sure how to implement the auto refresh option and how to automatically refresh it...

This is one of my code(ajax code)...

function message(clickedID){
        var ID = clickedID;
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function(){
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("chatBox").innerHTML = xmlhttp.responseText;
            }
        };
        xmlhttp.open("POST","retrieveMsg.php?q=" +ID,true);
        xmlhttp.send();
        }

Hopefully I can get an explanation on this and some examples Thanks in advance !

topacoBoy
  • 197
  • 2
  • 4
  • 17
  • Define "auto refresh"? Under what circumstances do you want the browser to make a new ajax request? – Quentin Nov 24 '15 at 10:17
  • When the other user sends a new input... It should auto check if there is some changes in the db..if yes then it refreshes...is it possible ? and did i answer your question ? @Quentin – topacoBoy Nov 24 '15 at 10:19
  • so there's no way to do it without plugins ? @Quentin – topacoBoy Nov 24 '15 at 10:31
  • What leads you to that conclusion? The accepted answer on the duplicate question opens with "Use WebSockets" which are a web standard. – Quentin Nov 24 '15 at 10:32
  • Sry, like i said, im still new. So im not really sure how it works. Will try to do some research on it .... @Quentin – topacoBoy Nov 24 '15 at 10:33

0 Answers0