Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/11/2010, 13:54
krisishack
 
Fecha de Ingreso: noviembre-2010
Mensajes: 12
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: como refrescar solo el cuerpo de un sitio

colocas un <div id="micapa"></div> dentro de la pagina es mas nisiquiera deverias usar taantos archivos de php, y usas la funcion de ajax que es get o post mira este ejemplo,


Código Javascript:
Ver original
  1. <script>
  2. function objetus(file) {
  3. xmlhttp=false;
  4. this.AjaxFailedAlert = "Su navegador no soporta las funcionalidades de este sitio y podria experimentarlo de forma diferente a la que fue pensada. Por favor habilite javascript en su navegador para verlo normalmente.\n";
  5.  this.requestFile = file;
  6.  this.encodeURIString = true;
  7.  this.execute = false;
  8.  if (window.XMLHttpRequest) {
  9.             this.xmlhttp = new XMLHttpRequest();
  10.             if (this.xmlhttp.overrideMimeType) {
  11.                 this.xmlhttp.overrideMimeType('text/xml');
  12.             }
  13.         }
  14.         else if (window.ActiveXObject) { // IE
  15. try {
  16.   this.xmlhttp  = new ActiveXObject("Msxml2.XMLHTTP");
  17. }catch (e) {
  18.  try {
  19.   this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  20.   } catch (e) {
  21.    this.xmlhttp = null;
  22.    }
  23.        }
  24.  if (!this.xmlhttp  && typeof XMLHttpRequest!='undefined') {
  25.                 this.xmlhttp = new XMLHttpRequest();
  26.     if (!this.xmlhttp){
  27.    this.failed = true;
  28.   } } }
  29.  return this.xmlhttp ;
  30.  }
  31.  
  32. function recibeid(_pagina,valorget,valorpost,capa){
  33. ajax=objetus("id.php?");
  34. if(valorpost!=""){
  35. ajax.open("POST", "id.php?"+valorget+"&tiempo="+new Date().getTime(),true);
  36. } else {
  37. ajax.open("GET", "id.php?"+valorget+"&tiempo="+new Date().getTime(),true);
  38. }
  39. ajax.onreadystatechange=function() {
  40.  if (ajax.readyState==1){
  41.   document.getElementById(capa).innerHTML = "<img src='loadingcircle.gif' align='center'> Aguarde por favor...";
  42.   }
  43.   if (ajax.readyState==4) {
  44.    if(ajax.status==200)
  45.    {document.getElementById("prueba").value = ajax.responseText;}
  46.    else if(ajax.status==404)
  47.                                              {
  48.  capa.innerHTML = "La direccion no existe";
  49.                                              }
  50.                            else
  51.                                              {
  52.                             capa.innerHTML = "Error: ".ajax.status;
  53.                                              }
  54. }
  55. }
  56. if(valorpost!=""){
  57. ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  58. ajax.send(valorpost);
  59. } else {
  60. ajax.send(null);
  61. }
  62. }
  63. </script>

y pa cambiar de archivo a archivo usas esto para que se imprima en tu div

<a href="javascript:recibeid('mipagina.php','variable getenviada=enviaste solo get','','micapa')">Mi Enlace GET</a>