Foros del Web » Programando para Internet » Javascript »

Recargar tabla con Ajax

Estas en el tema de Recargar tabla con Ajax en el foro de Javascript en Foros del Web. Buenas, Tengo este script POST de AJAX: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript : Ver original function form ( ) {             ...
  #1 (permalink)  
Antiguo 15/01/2013, 10:58
 
Fecha de Ingreso: junio-2011
Mensajes: 342
Antigüedad: 12 años, 10 meses
Puntos: 5
Exclamación Recargar tabla con Ajax

Buenas,

Tengo este script POST de AJAX:


Código Javascript:
Ver original
  1. function form(){
  2.    
  3.         var icao = document.getElementById('icao').value;
  4.         var name = document.getElementById('name').value;
  5.         var weightempty = document.getElementById('weightempty').value;
  6.         var weightfull = document.getElementById('weightfull').value;
  7.         var cargofull = document.getElementById('cargofull').value;
  8.         var cruisespeed = document.getElementById('cruisespeed').value;
  9.         var range = document.getElementById('range').value;
  10.         var price = document.getElementById('price').value;
  11.         var firstclassseats = document.getElementById('firstclassseats').value;
  12.         var businessclassseats = document.getElementById('businessclassseats').value;
  13.         var economyclassseats = document.getElementById('economyclassseats').value;
  14.         ajax.open("POST","new_aircraft_process.php",true);
  15.         ajax.onreadystatechange=function(){
  16.             if(ajax.readyState==4)
  17.             {
  18.             var respuesta=ajax.responseText;
  19.             document.getElementById('result').innerHTML=ajax.responseText;
  20.             $("#newaircraftdialog").dialog('close');
  21.        
  22.             $("#loadingdialog").dialog('close');
  23.             }
  24.         }
  25.     ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  26.     ajax.send("icao="+icao+"&name="+name+"&weightempty="+weightempty+"&weightfull="+weightfull+"&cargofull="+cargofull+"&cruisespeed="+cruisespeed+"&range="+range+"&price="+price+"&firstclassseats="+firstclassseats+"&businessclassseats="+businessclassseats+"&economyclassseats="+economyclassseats);
  27.     $("#loadingdialog").dialog('open');
  28.     }

Lo que quiero es que una vez que termine de realizar el POST. Que me actualice esta tabla PHP, porque al hacer el form, se mustra la tabla pero con los datos antiguos y no añade el nuevo porque no se ha recargado:

Código PHP:
Ver original
  1. $query = "SELECT * FROM aircrafts ORDER BY ICAO ASC LIMIT " . (($pagination->get_page() - 1) * $records_per_page) . ", " . $records_per_page;
  2.  
  3. $result = mysql_query($query);
  4. if (!$result)
  5. {
  6. die (mysql_error());
  7. }
  8.  
  9. echo "<table border='0' cellspacing='0'>";
  10. echo "<tr><th class=tabletitles>ICAO</th><th class=tabletitles>Name</th><th class=tabletitles>Weight Empty</th><th class=tabletitles>Weight Full</th><th class=tabletitles>Cargo Full</th><th class=tabletitles>Range</th><th class=tabletitles>Price</th><th class=tabletitles>First Class Seats</th><th class=tabletitles>Business Class Seats</th><th class=tabletitles>Economy Class Seats</th><th class=tabletitles>Edit</th><th class=tabletitles>Delete</th></tr>";
  11.  
  12. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
  13.     if($i++%2==0){
  14.        $color="#FFFFFF";
  15.     }else{
  16.        $color="#CCCCCC";
  17.     }
  18.  
  19.     ?>
  20.  
  21.     <tr bgcolor='<?php echo $color; ?>' onmouseover="this.style.background='#ABFB04';" onmouseout="this.style.background='<?php echo $color; ?>';">
  22.     <?php
  23.  
  24. echo "<td class=tablelist>";
  25.  
  26. echo $row["ICAO"] . '</td><td class=tablelist>';
  27.  
  28. echo $row["Name"] . '</td><td class=tablelist>';
  29.  
  30. echo $row["WeightEmpty"] . '</td><td class=tablelist>';
  31.  
  32. echo $row["WeightFull"] . '</td><td class=tablelist>';
  33.  
  34. echo $row["CargoFull"] . '</td><td class=tablelist>';
  35.  
  36. echo $row["Range"] . '</td><td class=tablelist>';
  37.  
  38. echo $row["Price"] . '</td><td class=tablelist>';
  39.  
  40. echo $row["FirstClassSeats"] . '</td><td class=tablelist>';
  41.  
  42. echo $row["BusinessClassSeats"] . '</td><td class=tablelist>';
  43.  
  44. echo $row["EconomyClassSeats"]. '</td><td class=tablelist>';
  45.  
  46. echo "<img src=\"./images/info.png\" onclick=\"edit('".$row["ICAO"]."')\"></td><td class=tablelist>";
  47.  
  48. echo "<img src=\"./images/cross.png\" onclick=\"delete('".$row["ICAO"]."')\">";
  49.  
  50. }
  51.  
  52. echo "</table>";
  #2 (permalink)  
Antiguo 15/01/2013, 14:08
 
Fecha de Ingreso: junio-2011
Mensajes: 342
Antigüedad: 12 años, 10 meses
Puntos: 5
Exclamación Respuesta: Recargar tabla con Ajax

Una ayudita?

Etiquetas: ajax, html, php, tabla
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:02.