天哪,还有一个关于 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/