AJAX responseXML errores

He tenido algunos problemas extraños a la hora de realizar una solicitud AJAX y manejar la respuesta.

Estoy haciendo una llamada ajax para un archivo xml. sin embargo, cuando recibo la respuesta, la propiedad xhr.responseText funciona bien en firefox pero no en IE. Otra cosa es que estoy intentando acceder a xhr.responseXML como XMLDocument, pero en Firefox me dice que xhr.response XML no está definido, es decir, ni siquiera me muestra el error indefinido ni muestra la salida.

Este es el código que estoy usando para hacer la solicitud:

<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 && xhr.status == 0 ||
                        (xhr.status >= 200 && xhr.status < 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 && xhr.responseText != null &&
                xhr.responseXML != undefined && 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>

y así es como estoy llamando a la función para probar los resultados:

<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>

Este es también mi primer intento de trabajar con AJAX, por lo que podría haber algo que no estoy viendo bien. He estado buscando locos por cualquier indicación de por qué o cómo solucionarlo, pero no hay suerte allí. Cualquier idea sería genial.

EDITAR:

Sé que esto sería mejor con un marco, pero el jefe no quiere agregar un marco para solo una funcionalidad ajax ('solo' no es una palabra justa para ajax: P). Así que lo estoy haciendo con javascript puro.

El archivo XML está bien formado, lo veo bien en el navegador web, pero para completar este es el archivo de prueba que estoy usando:

<code><?xml version="1.0" encoding="utf-8"?>
<rooms>
  <room id="Blue_Room">
    <administrator>somebody@department</administrator>
    <schedule>
      <event>
        <requester>
          <name>Johnny Bravo</name>
          <email>jbravo@department</email>
        </requester>
        <date>2009/09/03</date>
        <start_time>11:00:00 GMT-0600</start_time>
        <end_time>12:00:00 GMT-0600</end_time>
      </event>
    </schedule>
  </room>
  <room id="Red_Room">
    <administrator>somebody@department</administrator>
    <schedule>
    </schedule>
  </room>
  <room id="Yellow_Room">
    <administrator>somebody@department</administrator>
    <schedule>
    </schedule>
  </room>
</rooms>
</code>

EDIT 2: Bueno, la buena noticia es que convencí a mi jefe de usar jQuery, la mala noticia es que AJAX aún me deja perplejo. Leeré más al respecto solo por curiosidad. Gracias por los consejos y le di el crédito de respuesta a Heat Miser porque era el consejo de trabajo más cercano.

Respuestas a la pregunta(7)

Su respuesta a la pregunta