title: AJAX responseXML errors
body: <p>I've been having some weird issues when it comes to make an AJAX request and handling the response.</p>
  
  <p>I am making an ajax call for an xml file. however when i get the response the xhr.responseText property works fine in firefox but not in IE.
  Another thing is that I am trying to access the xhr.responseXML as XMLDocument, but it tells me in firefox it tells me that xhr.responseXML is undefined in ie it doesnt even show me the undefined error or displays the output.</p>
  
  <p>This is the code I am using to make the request:</p>
  
  <pre><code>var ajaxReq = function(url, callback) {
      //initialize the xhr object and settings
      var xhr = window.ActiveXObject ?
              new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(),
      //set the successful connection function
          httpSuccess = function(xhr) {
              try {
                  // IE error sometimes returns 1223 when it should be 204
                  //  so treat it as success, see XMLHTTPRequest #1450
                  // this code is taken from the jQuery library with some modification.
                  return !xhr.status &amp;&amp; xhr.status == 0 ||
                          (xhr.status &gt;= 200 &amp;&amp; xhr.status &lt; 300) ||
                          xhr.status == 304 || xhr.status == 1223;
              } catch (e) { }
              return false;
          };
  
      //making sure the request is created
      if (!xhr) {
          return 404; // Not Found
      }
  
  
      //setting the function that is going to be called after the request is made
      xhr.onreadystatechange = function() {
          if (!httpSuccess(xhr)) {
              return 503; //Service Unavailable
          }
          if (xhr.responseXML != null &amp;&amp; xhr.responseText != null &amp;&amp;
                  xhr.responseXML != undefined &amp;&amp; xhr.responseText != undefined) {
              callback(xhr);
          }
      };
  
  
      //open request call
      xhr.open('GET', url, true);
  
      //setup the headers
      try {
          xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          xhr.setRequestHeader("Accept", "text/xml, application/xml, text/plain");
      } catch ( ex ) {
          window.alert('error' + ex.toString());
      }
  
      //send the request
      try {
          xhr.send('');
      } catch (e) {
          return 400; //bad request
      }
  
      return xhr;
  };
  </code></pre>
  
  <p>and this is how i am calling the function to test for results:</p>
  
  <pre><code>window.onload = function() {
      ajaxReq('ConferenceRoomSchedules.xml', function(xhr) {
          //in firefox this line works fine,
          //but in ie it doesnt not even showing an error
          window.document.getElementById('schedule').innerHTML = xhr.responseText;
          //firefox says ''xhr.responseXML is undefined'.
          //and ie doesn't even show error or even alerts it.
          window.alert(xhr.reponseXML.documentElement.nodeName);
      });
  }
  </code></pre>
  
  <p>This is also my first attempt to work with AJAX so there might be something that I am not looking at right.
  I've been searching crazy for any indications of why or how to fix it, but no luck there.
  any ideas would be great.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I know this would be better with a framework, but the boss doesn't want to add a framework for just an ajax functionality ('just' is not a fair word for ajax :P). So I am doing it with pure javascript.</p>
  
  <p>The XML file is well-formed, I see it well in the web browser, but for completion this is the testing file I am using:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;rooms&gt;
    &lt;room id="Blue_Room"&gt;
      &lt;administrator&gt;somebody@department&lt;/administrator&gt;
      &lt;schedule&gt;
        &lt;event&gt;
          &lt;requester&gt;
            &lt;name&gt;Johnny Bravo&lt;/name&gt;
            &lt;email&gt;jbravo@department&lt;/email&gt;
          &lt;/requester&gt;
          &lt;date&gt;2009/09/03&lt;/date&gt;
          &lt;start_time&gt;11:00:00 GMT-0600&lt;/start_time&gt;
          &lt;end_time&gt;12:00:00 GMT-0600&lt;/end_time&gt;
        &lt;/event&gt;
      &lt;/schedule&gt;
    &lt;/room&gt;
    &lt;room id="Red_Room"&gt;
      &lt;administrator&gt;somebody@department&lt;/administrator&gt;
      &lt;schedule&gt;
      &lt;/schedule&gt;
    &lt;/room&gt;
    &lt;room id="Yellow_Room"&gt;
      &lt;administrator&gt;somebody@department&lt;/administrator&gt;
      &lt;schedule&gt;
      &lt;/schedule&gt;
    &lt;/room&gt;
  &lt;/rooms&gt;
  </code></pre>
  
  <p><strong>EDIT 2:</strong>
  Well the good news is that I convinced my boss to use jQuery, the bad news is that AJAX still perplexes me. I'll read more about it just for curiousity. Thanks for the tips and I gave the answer credit to Heat Miser because he was the closest working tip.</p>