Results 1 to 3 of 3
  1. #1

    AJAX Javascript Questions.

    Hello,

    I coded a AJAX script that autoupdates a chat script every second in a div called "autoupdate".

    It detects if there are any updates on the "chat" - and if there is, it updates it appropriately.

    The problem is, that it works perfectly on FireFox, but doesn't in IE6/7. It seems to only update with an older cached version.

    The code is attached below (it might have a bit of PHP in it).

    If someone could help out - I'd really appreciate it.

    Code:
    var oldText;
    
    function loadurl(dest) { 
    	try { 
    		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); 
    	} catch (e) { 
    	} 
    
    	xmlhttp.onreadystatechange = triggered;
    	xmlhttp.open("GET", dest); 
    	xmlhttp.send(null); 
    } 
    
    function triggered() { 
    	if (oldText != xmlhttp.responseText) {
    		if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { 
    			document.getElementById("autoupdate").innerHTML = xmlhttp.responseText; 
    			oldText = xmlhttp.responseText;
    			'.$scrollTo.'
    		}
    	}
    }
    
    function update () {
    	loadurl("'.$path.'classes/autoupdate.php?'.$idaction.'='.$_GET['type'].'&'.$idsubaction.'='.$_GET['handler'].'");
    	t = setTimeout ("update ()",1000);
    }

  2. #2
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    IF its just IE using its cached version I usualy work around it by apenting some incromenting number on the end of the URL to force it not to cahce it. Like the time in seconds..

    Also you could just use the Prototype or Script.aculo.us libraries which have already dealt with all the crazy bugs in IE.

  3. #3
    I took your advice about adding some random number to the end of the URL - the caching problem is now gone - but it doesn't really "autoupdate".

    It still shows that there's an error. Apparently - IE7 tells me that line 16 is doing something wrong. Something about data not ready or something?

Posting Permissions

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