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

cargar multiples div por favor

Estas en el tema de cargar multiples div por favor en el foro de Frameworks JS en Foros del Web. Hola muy buenas, me gustaria saber como podria cargar varios div, estoy probando pero se queda el archico loading cargando pero no carga, pero carga ...
  #1 (permalink)  
Antiguo 21/03/2010, 15:30
Avatar de gachon  
Fecha de Ingreso: septiembre-2004
Ubicación: En Google
Mensajes: 462
Antigüedad: 19 años, 8 meses
Puntos: 3
cargar multiples div por favor

Hola muy buenas, me gustaria saber como podria cargar varios div, estoy probando pero se queda el archico loading cargando pero no carga, pero carga el segundo getdata. Cargando un solo div sale estupendamente, pero con dos ya no
este es mi codigo
Código PHP:
// here we define global variable
var ajaxdestination="";
function 
getdata(what,where) { // get data from source (what)
 
try {
   
xmlhttp window.XMLHttpRequest?new XMLHttpRequest():
          new 
ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (
e) { /* do nothing */ }

 
document.getElementById(where).innerHTML ="<div class='preload'><center><img src='imagenesfondo/ajax-loader.gif'></center></div>";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 
ajaxdestination=where;
 
xmlhttp.onreadystatechange triggered// when request finished, call the function to put result to destination DIV
 
xmlhttp.open("GET"what);
 
xmlhttp.send(null);
  return 
false;
}

function 
triggered() { // put data returned by requested URL to selected DIV
  
if (xmlhttp.readyState == 4) if (xmlhttp.status == 200
    
document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;

y este es el enlace de como intento cargar varios div
Código PHP:
<a href="javascript:void(0);" onclick="getdata('principal.html','contenidoarriba');getdata('principalservicios.html','contenidolateralderecho');" target="_top">Inicio</a
como ven llamo dos veces getdata pero solo carga la pagina principalservicios.html,porque principal.html se queda con mensaje de cargando a ver si por favor pueden ayudarme
saludos y muchas gracias

Última edición por gachon; 21/03/2010 a las 15:38
  #2 (permalink)  
Antiguo 22/03/2010, 05:39
Avatar de 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

Podrías probar con esto

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. for (i=0; i < ke; i++) {
  8.  
  9.  
  10.  try {
  11.    xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  12.           new ActiveXObject("Microsoft.XMLHTTP");
  13.  }
  14.  catch (e) { /* do nothing */ }
  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;" />
  #3 (permalink)  
Antiguo 22/03/2010, 09:04
Avatar de gachon  
Fecha de Ingreso: septiembre-2004
Ubicación: En Google
Mensajes: 462
Antigüedad: 19 años, 8 meses
Puntos: 3
Respuesta: cargar multiples div por favor

Muchas gracias por tu atencion Adler, pero no funciona.
  #4 (permalink)  
Antiguo 23/03/2010, 05:37
Avatar de 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;" />
  #5 (permalink)  
Antiguo 23/03/2010, 09:02
Avatar de gachon  
Fecha de Ingreso: septiembre-2004
Ubicación: En Google
Mensajes: 462
Antigüedad: 19 años, 8 meses
Puntos: 3
Respuesta: cargar multiples div por favor

muchas gracias Adler pero sigue sin funcionarme, pero lo arreglado con jquery, he conseguido cargar varios divs pero no consigo que salga la imagen de carga mira el codigo
Cita:
$(document).ready(function() {
$(".disenoweb").click(function(event) {

var imagenCargando = $("<div class='preload'><center><img src='imagenesfondo/ajax-loader.gif'></center></div>");//aqui intento poner una imagen de carga pero no sale

$("div#contenidoarriba").load('principal.html');
$("div#contenidolateralderecho").load('texto.html' );
});
});
haber si por favor puedes ayudarme, o abro un nuevo post para mi nueva duda
gracias de verdad por tu atencion

Etiquetas: ajax, favor, multiples
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 09:19.