Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

2 total

Crea Objeto XMLHTTPRequest

function ajaxFunction()
{
var xmlhttp;
try
  { 
 	 // Firefox, Opera 8.0+, Safari 
      xmlhttp=new XMLHttpRequest(); 
  }
catch (e)
    { 	 // Internet Explorer  
     try
    {   
     xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    catch (e)
    	{
	 try
     	 {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
	 }
   	catch (e)
    	    {
	     alert("Explorador no soporta--------AJAX!");  
	     xmlhttp= false;  
	    }
       }	// fin si no es Internet Explorer
     }   // fin si no es Firefox
return xmlhttp;
} // fin de crear objeto XMLHTTPRequest

Ajax-creaObjeto-XMLHttpRequest

// description of your code here

Código JavaScript:
/*
*Esta libreria es una libreria AJAX creada por Javier Mellado con la inestimable
*colaboracion de Beatriz Gonzalez.
*y descargada del portal AJAX Hispano http://www.ajaxhispano.com
*contacto javiermellado@gmail.com
*
*Puede ser utilizada, pasada, modificada pero no olvides mantener
*el espiritu del software libre y respeta GNU-GPL
*/ 
function creaAjax(){
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          // jajajajaja ... IE tambien entra aqui ...
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax = false;
          }
         }

         if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();
         }
         return objetoAjax;
}
                                     


2 total