ErlendHL 0 Junior Poster in Training

Hi! I am testing how to make an easy chat engine here.
First I used xmlhttp.open("GET",url+"?F="+FILE,[B]false[/B]); , but I noticed that it was very bad to use false, because then, every 2 seconds, the page stops working. (like you can't do anything for like 0.5 sec)
So I tried to use true, instead of false, but then this iis what shows up in firebug every 2 seconds (not exactly):

  • GET
    successful, and under Response, it stands just what it should be; the content of the .txt file that should be loaded into the variable text.
  • And then it stands that text is undefined...

Here is the code in the page:

function Update(){
                setTimeout("Update();",2000);
                text = Read('allMessages.txt','content',2);
                text = text.replace(/\n/g,'<br />');
                document.getElementById('content').innerHTML = text;
            }
            function Chat(){
                var fullMessage = '<b>'+document.getElementById('name').value + ':</b> ' + document.getElementById('message').value+'\n';
                Append(fullMessage,'allMessages.txt');
                document.getElementById('message').value="";
            }
            document.getElementById('name').value = prompt('Welcome to this beta chat engine, that does not work -.-.\n What is your name?',"");

Where Chat(); gets executed when the user presses Write.
And Update(); gets executed on body onload event, and as you see, it executes itself every 2 seconds.

Here is the external js document.

So Please help me! Thanks on advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.