Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Frustrated: AJAX Problem with IE
Old 05-05-2008, 11:44 PM Frustrated: AJAX Problem with IE
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I am having a problem with an AJAX problem. The following example works in FireFox but not IE. I have bolded the response function in which IE will not fire, but gives me an error "Object doesn't support this property or method".

The following example can be viewed on our development server:
http://66.101.212.20/~rsadmin/index.html

The included javascript:
Code:
var ajaxLiveHelpStatus;
function liveHelpStatus(url)
{
  ajaxLiveHelpStatus = new XMLHttp();
  ajaxLiveHelpStatus.sendRequest(url, null);
  ajaxLiveHelpStatus.http.response = function()
  {
    alert(1);
    if(ajaxLiveHelpStatus.http.status==200)
    {
      if(ajaxLiveHelpStatus.http.responseText==1)
      {
        document.getElementById('liveHelp').innerHTML='<a href="javascript:ShopTogether.preInitializeAndOpen(\'Customer\');">ONLINE</a>';
        setTimeout('liveHelpStatus("'+url+'");', 3000);
      }
      else
      {
        document.getElementById('liveHelp').innerHTML='offlineXXX';
      }
    }
  }
}
function XMLHttp()
{
  this.createRequestObject = function()
  {
    var rObj = false;
    if (typeof XMLHttpRequest == 'function')
    {
      rObj = new XMLHttpRequest();
    }
    else
    {
      var avers = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP', 'MSXML2.XMLHTTP.3.0',  'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.5.0'];
      for (var i = avers.length -1; i >= 0; i--)
      {
        try
        {
          rObj = new ActiveXObject(avers[i]);
        }
        catch(e) {}
      }
    }
    if(!rObj) throw new Error('XMLHttp (AJAX) not supported');
    return rObj;
  }
  this.sendRequest = function(url, param)
  {
    var method = (!param) ? 'GET' : 'POST';
    self.http.open(method, url, true);
    self.http.onreadystatechange = self.handleResponse;
    if (method == 'POST') self.http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    self.http.send((method == 'POST') ? param : null);
  }
 
  this.handleResponse = function()
  {
    if ((self.http.readyState == 4) && (typeof self.http.response == 'function')) self.http.response();
    if ((self.http.readyState == 1) && (typeof self.http.wait == 'function')) self.http.wait();
  }
 
  var self = this;
  this.http = this.createRequestObject();
 
  var response = null;
  var wait = null;
}
The HTML part of the page:
Code:
<script type="text/javascript" language="javascript">liveHelpStatus("<?php echo HTTP_SERVER . DIR_WS_CATALOG; ?>livehelp_status.php");</script>
Live Help is <span id="liveHelp">offline</span>

Any suggestions as to why this backfires in IE???
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-06-2008, 01:49 PM Re: Frustrated: AJAX Problem with IE
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I was finally able to solve the problem, but don't ask what the problem was, it was stupid little things that I didn't keep track of. I did however find a solution to another problem though. IE appears to cache AJAX responses and usually will only fire the handler function once UNLESS you add a no-cache on the requested AJAX page. This seems to take care of this.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Frustrated: AJAX Problem with IE
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09723 seconds with 12 queries