gettable.php にテーブルがあります。このテーブルは index.php に含まれています。私は AJAX 投稿を行い、投稿が完了したら AJAX でテーブルを更新したいと考えています。私はこれを見つけます:
$(document).ready(function(){
refreshTable();
});
function refreshTable(){
$('#table').load('getTable.php');
setTimeout(refreshTable, 5000);
}
これは私のAJAX POSTです:
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');
//I want to add here the code to refresh the table
}
}
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');
}
このように同じことを行うことは可能ですが、5秒ごとにいいえが必要な場合にのみ更新しますか?