$("#Save").click(function() {
var lastForm = $(".frm_product_group").size() - 1;
$(".frm_product_group").each(function (index) {
$.post("save_new_product_group.php", $(this).serialize(), function (data) {
if (data == false) {
alert("Error: Try again");
}
});
if (index == lastForm) {
window.location.href = "product_group.php";
}
});
});
在上面的代码中,窗口重定向到没有jquery.post(...)的product_group.php。如果我在window.location之前使用alert(...),则jquery.post()更新可以正常工作。我想这是jquery响应时间的问题。我无法整理出来。调用jquery,每个工作不正常
请帮忙。
@ box9:抱歉,没有处理您的建议。 – Iqbal 2010-12-11 12:51:19
@Iqbal - 发生了什么?窗口是否重定向到'product_group.php'?是否有任何帖子通过?我怀疑只有一个职位正在通过。 – 2010-12-11 12:59:07
@Iqbal - 更新了处理多个表单的答案,因为服务器响应可以以任何顺序返回并提前触发window.location.href更改。 – 2010-12-11 13:03:29