$xy('#simpan').click(function() {
$xy('input[id="cekbok[]"]:checked').each(function() {
var data = (this.value);
var div = (this.value);
var str = window.location.href;
var res = str.replace("wp-admin/options-general.php?page=katalogu-options", "/wp-content/plugins/katalog/includes/img/loading.gif");
var loading = ('<img src="'+res+'">') ;
$xy.ajax({
type : 'POST',
url : '../wp-content/plugins/katalogunique/proses2.php',
data: {
id : (this.value)
},
success:function (data) {
$xy('#result'+div).empty();
$xy('#result'+div).append(data);
$xy('#tz'+div).remove();
}
});
});
});
我的函数在循环中将复选框值发送到proses2.php
,但是当我运行此脚本时,它将立即运行所有ajax POST调用。我想要一个接一个地运行ajax请求,或者等到完成后,我该如何解决这个问题?jQuery Ajax等待每个函数
你是什么意思由_it将运行所有ajax POST_?多解释一点。并且,看着'$ xy('input [id =“cekbok []”]:checked')'你似乎有多个'checkbox'和相同的'ID',这是错误的'ID'必须是在任何给定的文件中都是唯一发布你的'HTML'。 – lshettyl
如果我检查10复选框,那么它将运行10 Ajax后proses2.php,是复选框ID是唯一的,这个脚本已经工作,但我想让它做1 1 ...谢谢 –
理想情况下你想要达到什么 – dreamweiver