lunes, 16 de febrero de 2009

Función para crear un XML Request Object válido

function devuelveXMLRequestObject {
xmlhttp=false;
this.requestFile = file;
this.encodeURIString = true;
this.execute = false;
this.AjaxFailedAlert = "Funcionalidades no soportadas.";

if (window.XMLHttpRequest) {

this.xmlhttp = new XMLHttpRequest();
if (this.xmlhttp.overrideMimeType) {
this.xmlhttp.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) {

//Internet Explorer

try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
this.xmlhttp = null;
}
}
if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') {
this.xmlhttp = new XMLHttpRequest();
if (!this.xmlhttp){
this.failed = true;
}
}
}
return this.xmlhttp ;
}

No hay comentarios: