[問題] .each如何配合$.ajax
我想利用.each的方式取得表單裡的每個id值
然後在.each的迴圈function裡面還要配合$.ajax去查詢php程式
程式碼
$("input[id^='pid_'][type='hidden']").each(
function()
{
pid = this.value;
alert('xx'+pid);
$.ajax(
{
type: "GET",
url: "jquery/chkdate.php",
data: "&sdate=111&edate=222",
success: function(msg){
alert(pid);
$('#datechk_'+pid).html(msg);
}
});
});
發現它會先執行完.each的所有迴圈之後、再執行 $.ajax、且只執行一次
(也就是alert 'xx' 會先全部跳出來、然後才跳一次 alert(pid);)
請問應該如何寫才能讓每個.each都能執行一次$.ajax
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.75.77.172
推
08/12 13:21, , 1F
08/12 13:21, 1F
→
08/12 13:22, , 2F
08/12 13:22, 2F
→
08/13 01:21, , 3F
08/13 01:21, 3F
→
08/13 20:44, , 4F
08/13 20:44, 4F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章