我的Ajax是這樣寫
$.ajax({
url: "ajax_insert_user_list.php",
data: 'lid='+lid+'&auid='+auid,
type: "POST",
dataType :'json',
success:function(data){
$.each(data,function(i,item){
$('#c_l_'+item.lid).html('('+item.count+')');
});
},
async: false
});
我想要把 success裡面的function 獨立出來,讓另外一個ajax事件也能利用
所以 我寫成這樣
function refresh(data)
{
$.each(data,function(i,item){
//alert(item.lid);
$('#c_l_'+item.lid).html('('+item.count+')');
});
}
success:refresh(data)
可是丟到Firefox看主控台卻出現以下的錯誤
data is not defined
[在這個錯誤中斷]
success:refresh(data),
請問該怎麼改才對 ,謝謝回答
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.126.209.219
→
06/19 15:54, , 1F
06/19 15:54, 1F
→
06/19 15:54, , 2F
06/19 15:54, 2F
→
06/19 15:54, , 3F
06/19 15:54, 3F
→
06/19 16:02, , 4F
06/19 16:02, 4F
→
06/19 16:03, , 5F
06/19 16:03, 5F
→
06/19 16:29, , 6F
06/19 16:29, 6F
→
06/19 16:30, , 7F
06/19 16:30, 7F