Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Prototype Vs. Objeto XMLHttp

Estas en el tema de Prototype Vs. Objeto XMLHttp en el foro de Frameworks JS en Foros del Web. Buen día Soy nuevo en el mundo de ajax, me surgio la duda de que es mejor usar (en cuanto a rapidez y eficiencia) prototype ...
  #1 (permalink)  
Antiguo 04/12/2013, 14:47
 
Fecha de Ingreso: diciembre-2012
Mensajes: 21
Antigüedad: 11 años, 4 meses
Puntos: 1
Prototype Vs. Objeto XMLHttp

Buen día
Soy nuevo en el mundo de ajax, me surgio la duda de que es mejor usar (en cuanto a rapidez y eficiencia) prototype o el objeto xmlhttp de ajax para cargar contenido en un div de forma dinámica. Uso lo siguiente:

en prototype:
Código Javascript:
Ver original
  1. <script type="text/javascript" src="javascript/prototype.js"></script>
  2.  
  3. <script type="text/javascript">
  4. function buscar(){
  5.    var url = "filtrar.php";
  6.    var pars = "busqueda="+$F('search')+"&j_campo="+$F('_filtrar')+"&estado="+$F('estado');
  7.    var myAjax = new Ajax.Updater( "resultados", url, { method: "post", parameters: pars, evalScripts: true });
  8. }
  9. </script>


Con el objeto xmlhttp:
Código Javascript:
Ver original
  1. function objetoAjax(){
  2.     var xmlhttp=false;
  3.     try {
  4.         xmlhttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');
  5.     } catch (e) {
  6.         try {
  7.            xmlhttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');
  8.         } catch (E) {
  9.             xmlhttp = false;
  10.           }
  11.     }
  12.  
  13.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  14.         xmlhttp = new XMLHttpRequest();
  15.     }
  16.     return xmlhttp;
  17. }
  18.  
  19. function buscar(){
  20.     var n=document.getElementById('search').value;
  21.     var campo=document.getElementById('_filtrar').value;
  22.     var estado=document.getElementById('estado').value;
  23.     divResultado = document.getElementById('resultados');
  24.     if(n==''){
  25.         divResultado.innerHTML="";
  26.         return;
  27.     }
  28.     var ajax=objetoAjax();
  29.       ajax.open("POST", "filtrar.php",true);
  30.       ajax.onreadystatechange=function() {
  31.         if (ajax.readyState==4) {
  32.             if(ajax.status==200)
  33.                 divResultado.innerHTML = ajax.responseText;
  34.         }else {
  35.             var cargando="<center><img width='20' height='20' style='vertical-align:sub' src='imagenes/loading.gif'/><span class='form'>Cargando...</span></center>";
  36.             document.getElementById("resultados").innerHTML = cargando;
  37.         }
  38.     }
  39.     ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  40.     ajax.send("busqueda="+n+"&j_campo="+campo+"&estado="+estado);
  41. }
  #2 (permalink)  
Antiguo 04/12/2013, 16:54
Avatar de IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Prototype Vs. Objeto XMLHttp

ponte a contar líneas de código y el resto lo hará tu lógica. las librerías como jquery, prototype, mootools, etc, están basada en javascript
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}

Etiquetas: ajax, javascript, prototype
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:23.