Ver Mensaje Individual
  #6 (permalink)  
Antiguo 24/09/2010, 09:33
JuanZapata
 
Fecha de Ingreso: febrero-2009
Ubicación: Barcelona
Mensajes: 15
Antigüedad: 15 años, 2 meses
Puntos: 0
Respuesta: Problemas con variables y ajax

Esta es la parte de ajax:

Código Javascript:
Ver original
  1. function objetoAjax(){
  2.     var xmlhttp=false;
  3.     try {
  4.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  5.     } catch (e) {
  6.         try {
  7.            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  8.         } catch (E) {
  9.             xmlhttp = false;
  10.           }
  11.     }
  12.  
  13.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  14.         xmlhttp = new XMLHttpRequest();
  15.     }
  16.     return xmlhttp;
  17. }
  18.  
  19. function refrescarMBI()
  20.       {
  21.           ajax=nuevoAjax();
  22.           ajax.open("GET", "URL");
  23.           ajax.onreadystatechange=function()
  24.           {
  25.               if (ajax.readyState==4)
  26.               {
  27.                   document.getElementById("mbi").innerHTML = ajax.responseText;
  28.               }
  29.           }
  30.           ajax.send(null)
  31.       }

Este es el codigo del vinculo:

Código Javascript:
Ver original
  1. echo "<a style=\"text-decoration:bold;cursor:pointer;\"   onclick=\"pedirDatos('".$row['fmg_id']."','cast','".$row['fmg_familia']."','".$row['fmg_titulo']."')\" onmousedown=\"refrescarMBI()\"  >".$row['fmg_titulo_select']."</a><br/>";

Y este es el PHP en el cual esta ese boton y el div que quiero refrescar:

Código PHP:
Ver original
  1. <html>
  2. <head>
  3.     <meta http-equiv="Content-Type" content="text/html; charset=ISO 8859-1">
  4.     <script language="JavaScript" type="text/javascript" src="ajax.js"></script>
  5. </head>
  6. <body>
  7. <div class="menu" id="mbi">
  8.     <?php
  9.     //conexion a base de datos
  10.     $bd_host = "localhost";
  11.     $bd_usuario = "xxxxx";
  12.     $bd_password = "xxxxx";
  13.     $bd_base = "xxxxx";
  14.     $con = mysql_connect($bd_host, $bd_usuario, $bd_password);
  15.     mysql_select_db($bd_base, $con);
  16.     $menu=$_SESSION['menu'];
  17.     $familia='mbia';
  18.     $sql=mysql_query("SELECT * FROM fmg WHERE fmg_familia='$familia' AND fmg_lang='$lang' ORDER BY fmg_orden ASC",$con);
  19.     echo "<a href='index.php?lang=$lang' target=_self>home</a>";
  20.     echo "<br /><br />";
  21.     while($row = mysql_fetch_array($sql))
  22.         {
  23.             if ($row['fmg_id']==$menu)
  24.             {
  25.                 echo "<a style=\"text-decoration:bold;cursor:pointer;\"   onclick=\"pedirDatos('".$row['fmg_id']."','cast','".$row['fmg_familia']."','".$row['fmg_titulo']."')\" onmousedown=\"refrescarMBI()\"  >".$row['fmg_titulo_select']."</a><br/>";
  26.                 echo "<br />";
  27.             }
  28.             else {
  29.                 echo "<a style=\"text-decoration:bold;cursor:pointer;\" onclick=\"pedirDatos('".$row['fmg_id']."','cast','".$row['fmg_familia']."','".$row['fmg_titulo']."')\"  onmousedown=\"refrescarMBI()\"  >".$row['fmg_titulo']."</a><br/>";
  30.                 echo "<br />";
  31.             }
  32.         }
  33.     echo "<br />";
  34.     echo "<br />";
  35.     $familia2='mbia_2';
  36.     $sql2=mysql_query("SELECT * FROM fmg WHERE fmg_familia='$familia2' AND fmg_lang='$lang' ORDER BY fmg_orden ASC",$con);
  37.     while($row = mysql_fetch_array($sql2))
  38.         {
  39.             echo "<a style=\"text-decoration:bold;cursor:pointer;\" onclick=\"pedirDatos('".$row['fmg_id']."','cast','".$row['fmg_familia']."','".$row['fmg_titulo']."')\">".$row['fmg_titulo']."</a><br/>";
  40.             echo "<br />";
  41.         }
  42.     ?>
  43. </div>
  44. </body>
  45. </html>


DIme si hace falta algo mas.

Gracias Adler