DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: I hate IE - responsetext help

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    I hate IE - responsetext help

    I'm creating an active user script using Javascript/PHP. My code works fine in Firefox, but when I try it in IE I'm running into problems. The script updates a list of which users are logged into the page every 20 seconds or so. In firefox, this is working fine. In IE, it updates once to create the list, but in subsequent updates it just continues showing the same list, even if a user signs out. Code is listed below.

    Code:
     <script language="JavaScript">
       var user;
       var AJAX;
    
       function initAJAX() {
           user = document.getElementById('user').value;
           try {
          AJAX = new XMLHttpRequest();
           } catch(e) {
          try {
              AJAX = new ActiveXObject("Msxml2.XMLHTTP");
          } catch(e) {
              try {
             AJAX = new ActiveXObject("Microsoft.XMLHTTP");
              } catch(e) {
             alert("Your browser can't use AJAX!");
             return false;
              }
          }
           }
           setRefresh(20000);
       }
          
    
       function setRefresh(num) {
           setTimeout("UpdateActive()", num);
       }
    
       function UpdateActive() {
           var disp = document.getElementById('ShowUsers');
           AJAX.onreadystatechange = function() {
          if(AJAX.readyState == 4 || AJAX.readyState == "complete") {
              disp.innerHTML = AJAX.responseText;
          }
           }
    
           var ran= Math.floor(Math.random() * 1001);
           AJAX.open("GET", "getactive.php?user="+user+"&ie="+ran, true);
           AJAX.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")
           AJAX.send(null);
           setRefresh(30000);
       }
    
          
        </script>
    I'm assuming the PHP code works fine, since it does for firefox, but if you'd like to see it I'd be more than happy to post it.

  2. #2
    Join Date
    Nov 2008
    Posts
    2
    PHP code is returning:

    Code:
    "Name<br/>Name<br/>" etc.

  3. #3
    Join Date
    Mar 2007
    Location
    Bangalore, India
    Posts
    247
    In the PHP code, add an expires header. That should solve the problem. IE caches the response and uses that without checking the server for updates unless you add an expires header.

Similar Threads

  1. How to execute responseText?
    By pondugud in forum AJAX
    Replies: 0
    Last Post: 05-13-2008, 09:48 AM
  2. Replies: 0
    Last Post: 03-13-2007, 09:43 AM
  3. Replies: 2
    Last Post: 02-16-2007, 03:13 PM
  4. don't ya hate it when... (small rant)
    By Aaron Anderson in forum .NET
    Replies: 0
    Last Post: 06-11-2001, 08:25 PM
  5. don't ya hate it when... (small rant)
    By Aaron Anderson in forum .NET
    Replies: 0
    Last Post: 06-11-2001, 08:25 PM

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center