Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/10/2010, 06:40
SeaPirates
 
Fecha de Ingreso: enero-2009
Ubicación: España
Mensajes: 786
Antigüedad: 15 años, 3 meses
Puntos: 9
Actualizar 2 divs sin recargar

He intentado que se actualicen 2 divs al mismo tiempo sin recargar, pero al intentar hacerlo, se me actualiza uno pero el otro no.. Lo que he hecho es repetir algunas funciones, pero no me ha funcionado.

Código Javascript:
Ver original
  1. var seconds = 1;
  2. var divid = "room";
  3. var url = "/maps/map_<?echo $_GET['map']; ?>.php";
  4. var pos = "posicion.php";
  5.  
  6. function refreshdiv(){
  7.  
  8. var xmlHttp;
  9. try{
  10. xmlHttp=new XMLHttpRequest();
  11. }
  12. catch (e){
  13. try{
  14. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  15. }
  16. catch (e){
  17. try{
  18. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  19. }
  20. catch (e){
  21. alert("Tu explorador no soporta AJAX.");
  22. return false;
  23. }
  24. }
  25. }
  26.  
  27. fetch_unix_timestamp = function()
  28. {
  29. return parseInt(new Date().getTime().toString().substring(0, 10))
  30. }
  31.  
  32. var timestamp = fetch_unix_timestamp();
  33. var nocacheurl = url+"?t="+timestamp;
  34. var nocachepos = pos+"?t="+timestamp;
  35.  
  36.  
  37.  
  38. xmlHttp.onreadystatechange=function(){
  39. if(xmlHttp.readyState==4){
  40. document.getElementById('room').innerHTML=xmlHttp.responseText;
  41. document.getElementById('pos').innerHTML=xmlHttp.responseText;
  42. setTimeout('refreshdiv()',seconds*1000);
  43. }
  44. }
  45. xmlHttp.open("GET",nocacheurl,true);
  46. xmlHttp.open("GET",nocachepos,true);
  47. xmlHttp.send(null);
  48. }
  49. window.onload = function startrefresh(){
  50. setTimeout('refreshdiv()',seconds*1000);
  51. }
  52. refreshdiv();