Ajax刷新表

时间:2013-01-16 15:37:55

标签: ajax

我在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秒钟没有时才刷新它?

0 个答案:

没有答案