Created
November 9, 2012 18:24
-
-
Save fmagrosoto/4047345 to your computer and use it in GitHub Desktop.
Inicialización para AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript Document | |
// Inicialización de AJAX multiplataforma | |
// Otra alternativa para instanciar el objeto. | |
// Sólo es necesario crear un nuevo objeto con el nombre de la instancia | |
// ej: XMLHttp = crearInstancia(); | |
function crearInstancia() { | |
XMLHttp = false; | |
if (window.XMLHttpRequest) { | |
return new XMLHttpRequest(); | |
} else if (window.ActiveXObject) { | |
var versiones = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; | |
for (var i=0;i<versiones.length;i++) { | |
try { | |
XMLHttp = new ActiveXObject(versiones[i]); | |
if (XMLHttp) { | |
return XMLHttp; | |
break; | |
} | |
} catch (e) {}; | |
} | |
} | |
} | |
/* AJAX ha quedado inicializado */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment