IE7- Ajax成功数据已经过时了

时间:2013-12-19 20:44:17

标签: jquery ajax internet-explorer

哦,男孩,关于IE 7和Ajax的另一个问题。我已经阅读了很多关于IE缓存和诸如此类的帖子,我仍然无法在IE 7中使用此代码。我已尝试使用Ajax设置缓存清除并禁用它但成功时,数据就是表格所看到的比如在添加新行之前。也许它的东西非常简单,我只是忽视它。

//Submit the addData for PHP processing, remove all the additional rows then hide the div
$('input#addSubmit').click( function() {

    $.post( 'shepherd.php?a=save_data', $('form#addForm').serialize());

    //The number of rows is abratrairy so we have to find out how many there are
    //so we can slice from mainRow to the submit button row
    //The mainRow is the 2nd index

    var addLength = $("table#addTable tr").length - 1;
    $("table#addTable tr").slice(3,addLength).remove();

    rowCount = 2;
    lastRow = $('tr#mainRow');

    //Remove values from the main row
    $(".addMainData").val("")

    //Pull an updated version of the main table then delete the current one

    $.post( 'shepherd.php?a=refresh_table&buster=' + new Date().getTime(),
            function(jquery_data) {
                //alert(jquery_data);
                $('div#mainContent').empty().html(jquery_data);
            });     

    $("div#addDiv").hide(400);
});

1 个答案:

答案 0 :(得分:3)

你需要在第一个回调中进行第二次AJAX调用,这样它才能在第一次更新数据库之前运行。

//Submit the addData for PHP processing, remove all the additional rows then hide the div
$('input#addSubmit').click( function() {

    $.post( 'shepherd.php?a=save_data', $('form#addForm').serialize(), function() {

        //The number of rows is abratrairy so we have to find out how many there are
        //so we can slice from mainRow to the submit button row
        //The mainRow is the 2nd index

        var addLength = $("table#addTable tr").length - 1;
        $("table#addTable tr").slice(3,addLength).remove();

        rowCount = 2;
        lastRow = $('tr#mainRow');

        //Remove values from the main row
        $(".addMainData").val("")

        //Pull an updated version of the main table then delete the current one

        $.post( 'shepherd.php?a=refresh_table&buster=' + new Date().getTime(),
                function(jquery_data) {
                    //alert(jquery_data);
                    $('div#mainContent').empty().html(jquery_data);
                });     

        $("div#addDiv").hide(400);
    });
});