jquery - IE7-Ajax 成功数据已过时

标签 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);
});

最佳答案

您需要在第一个 AJAX 调用的回调中执行第二个 AJAX 调用,以便在第一个 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);
    });
});

关于jquery - IE7-Ajax 成功数据已过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20691317/

相关文章:

jQuery - 让一个元素随着你在 div 中的页面向下滚动

javascript - 在元素内创建新元素

javascript - jQuery 自动完成插件,多项选择覆盖之前的选择

javascript - 使用 AJAX 的 Bootstrap 模式登录

javascript - 如何在 jsonp 调用上接收有关 404,409 和其他服务器错误的通知

internet-explorer - PowerShell Internet Explorer Com 对象选择类下拉菜单项

javascript - Jquery - 在输入时,使用跨度类获取 td 内的跨度值

jquery ajax加载某些div

javascript - 在 HTML 文件中包含 XML 内联

javascript - jQuery 代码适用于 Chrome,不适用于 IE9