Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/05/2009, 03:16
matak
 
Fecha de Ingreso: julio-2008
Ubicación: Alcañiz-Teruel-España
Mensajes: 182
Antigüedad: 15 años, 10 meses
Puntos: 5
Respuesta: llamadas simultaneas en AJAX

Si te he entendido bien a mi me paso eso. Lo solucione llamando de forma diferente a los objetos ajax, el problema es que tube que crear 2 funciones diferentes que hacen lo mismo con la salvedad que los nombres de los objetos difieren. Se que no es muy eficiente, pero en su día no encontré otra solución.

pe:

Código javascript:
Ver original
  1. //Funcion que crea el objeto ajax
  2. function objetoAjax(){
  3.     var xmlhttp=false;
  4.     try {
  5.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  6.     } catch (e) {
  7.         try {
  8.            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  9.         } catch (E) {
  10.             xmlhttp = false;
  11.     }
  12.     }
  13.  
  14.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  15.         xmlhttp = new XMLHttpRequest();
  16.     }
  17.     return xmlhttp;
  18. }
  19.  
  20. function f1(url,divcontenido){
  21.     ajax1=objetoAjax();
  22.     ajax1.open("POST", url, true);
  23.     ajax1.onreadystatechange=function() {
  24.         if (ajax1.readyState==4) {
  25.             divcontenido.innerHTML = ajax1.responseText
  26.         }
  27.     }
  28.     ajax1.send(null)
  29. }
  30.  
  31.  
  32. function f2(url,divcontenido){
  33.     ajax2=objetoAjax();
  34.     ajax2.open("POST", url, true);
  35.     ajax2.onreadystatechange=function() {
  36.         if (ajax2.readyState==4) {
  37.             divcontenido.innerHTML = ajax2.responseText
  38.         }
  39.     }
  40.     ajax2.send(null)
  41. }

Código html:
Ver original
  1. <input type='button' value='actualiza' onclick="javascript:f1('prueba1.php',document.getElementById('div1'));javascript:f2('prueba2.php',document.getElementById('div2'));">
  2. <div style="width:50%;float:left" id="div1"></div>
  3. <div style="width:50%;float:left" id="div2"></div>

prueba1.php

Código html:
Ver original
  1. <font style="font-size:30pt;color:red;">contenido prueba1.php</font>

prueba2.php

Código html:
Ver original
  1. <font style="font-size:30pt;color:green;">contenido prueba2.php</font>

Ya dirás, Saludos
__________________
Si quieres puedes y si puedes debes. Imposible is nothing!!!

Última edición por matak; 13/05/2009 a las 03:54