Tengo este script POST de AJAX:
Código Javascript:
Ver original
function form(){ var icao = document.getElementById('icao').value; var name = document.getElementById('name').value; var weightempty = document.getElementById('weightempty').value; var weightfull = document.getElementById('weightfull').value; var cargofull = document.getElementById('cargofull').value; var cruisespeed = document.getElementById('cruisespeed').value; var range = document.getElementById('range').value; var price = document.getElementById('price').value; var firstclassseats = document.getElementById('firstclassseats').value; var businessclassseats = document.getElementById('businessclassseats').value; var economyclassseats = document.getElementById('economyclassseats').value; ajax.open("POST","new_aircraft_process.php",true); ajax.onreadystatechange=function(){ if(ajax.readyState==4) { var respuesta=ajax.responseText; document.getElementById('result').innerHTML=ajax.responseText; $("#newaircraftdialog").dialog('close'); $("#loadingdialog").dialog('close'); } } ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); ajax.send("icao="+icao+"&name="+name+"&weightempty="+weightempty+"&weightfull="+weightfull+"&cargofull="+cargofull+"&cruisespeed="+cruisespeed+"&range="+range+"&price="+price+"&firstclassseats="+firstclassseats+"&businessclassseats="+businessclassseats+"&economyclassseats="+economyclassseats); $("#loadingdialog").dialog('open'); }
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
$query = "SELECT * FROM aircrafts ORDER BY ICAO ASC LIMIT " . (($pagination->get_page() - 1) * $records_per_page) . ", " . $records_per_page; $result = mysql_query($query); if (!$result) { die (mysql_error()); } echo "<table border='0' cellspacing='0'>"; 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>"; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ if($i++%2==0){ $color="#FFFFFF"; }else{ $color="#CCCCCC"; } ?> <tr bgcolor='<?php echo $color; ?>' onmouseover="this.style.background='#ABFB04';" onmouseout="this.style.background='<?php echo $color; ?>';"> <?php echo "<td class=tablelist>"; echo $row["ICAO"] . '</td><td class=tablelist>'; echo $row["Name"] . '</td><td class=tablelist>'; echo $row["WeightEmpty"] . '</td><td class=tablelist>'; echo $row["WeightFull"] . '</td><td class=tablelist>'; echo $row["CargoFull"] . '</td><td class=tablelist>'; echo $row["Range"] . '</td><td class=tablelist>'; echo $row["Price"] . '</td><td class=tablelist>'; echo $row["FirstClassSeats"] . '</td><td class=tablelist>'; echo $row["BusinessClassSeats"] . '</td><td class=tablelist>'; echo $row["EconomyClassSeats"]. '</td><td class=tablelist>'; echo "<img src=\"./images/info.png\" onclick=\"edit('".$row["ICAO"]."')\"></td><td class=tablelist>"; echo "<img src=\"./images/cross.png\" onclick=\"delete('".$row["ICAO"]."')\">"; } echo "</table>";