Ver Mensaje Individual
  #4 (permalink)  
Antiguo 23/03/2010, 05:37
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: cargar multiples div por favor

Hola

De acuerdo, no funciona. ¿Pero cual es el problema? ¿Marca algún error, no hace lo que esperas que haga, no hace nada, ...?

Prueba así

Código Javascript:
Ver original
  1. // here we define global variable
  2. var ajaxdestination="";
  3. function getdata(what,where) { // get data from source (what)
  4. ke = what.split("/");
  5. donde = where.split("/");
  6.  
  7.  
  8.  try {
  9.    xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  10.           new ActiveXObject("Microsoft.XMLHTTP");
  11.  }
  12.  catch (e) { /* do nothing */ }
  13.  
  14. for (i=0; i < ke; i++) {
  15.  
  16.  document.getElementById(donde[i]).innerHTML ="<div class='preload'><center><img src='imagenesfondo/ajax-loader.gif'></center></div>";
  17. // we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
  18.  ajaxdestination=donde[i];
  19.  xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
  20.  xmlhttp.open("GET", ke[i]);
  21.  xmlhttp.send(null);
  22.   return false;
  23. }
  24.  
  25. }
  26.  
  27. function triggered() { // put data returned by requested URL to selected DIV
  28.   if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
  29.     document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
  30. }  
  31.  
  32.  
  33. <a href="javascript:void(0);" onclick="getdata('principal.html/principalservicios.html','contenidoarriba/contenidolateralderecho'); target="_top">Inicio</a>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />