www.webdeveloper.com
Results 1 to 5 of 5

Thread: flashing text box...

  1. #1
    Join Date
    May 2010
    Location
    USS Enterprise-A
    Posts
    38

    flashing text box...

    Hello,
    I have made some code for a chatbox,but after making a timer which makes my chatbox be updated every 100ms I started having the problem that I don't see anything else other than what was posted until I entered the page, and the rest appears shortly when i send any message.
    Here is the update function:
    Code:
    function reload(){
      try{
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    		try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				alert("Your browser broke!");
    				return false;
    			}
    		}
    	}
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4){
    			var p=document.getElementById('posts');
    			p.value=ajaxRequest.responseText;//put what reload.php returns in my ChatBox named "posts"
    		}
    	}
    	ajaxRequest.open("GET", "reload.php", true);//start reload.php which gives the browser the contents of Message.txt(which i checked numerous times)
    	ajaxRequest.send(null);
    }
    Can you tell me what is happening?

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    I'm not sure how you expect someone to solve the problem for you when all you have posted is a bare bones ajax function.

    This is just another time I wish I hadn't skipped school the day they taught mind reading .

    Imo if you post the code surrounding the call to reload() and the code inside reload.php you will have a better chance of someone pointing you in the right direction.

  3. #3
    Join Date
    May 2010
    Location
    USS Enterprise-A
    Posts
    38
    Here's the code surrounding the call to reload():
    Code:
    function setTimer(){
      setInterval("reload()",100);
    }
    setTimer is called on entering the page, so don't worry about it
    reload.php:
    PHP Code:
    $fhandle=fopen("Message.txt","r");
    $contain=fread($fhandle,filesize("Message.txt"));
    echo 
    $contain;
    fclose($fhandle); 
    Last edited by Stelar; 05-18-2010 at 06:46 AM.

  4. #4
    Join Date
    May 2010
    Location
    USS Enterprise-A
    Posts
    38
    *bump*

  5. #5
    Join Date
    May 2010
    Location
    USS Enterprise-A
    Posts
    38
    *bump*

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles