2
我在我的網站上有一個儀表板,其中包含一些表中的條目,表中的每個條目都有一個delete
按鈕。當用戶點擊delete
按鈕時,會發生Ajax調用,並且正在刪除回調函數中的該條目。我的代碼:刪除ajax回調問題
$(".del").live({
click: function() {
$.post("/Home/DeleteTemplate", {
name: $(this).parent().siblings("td:first").children("a").html()
}, function (data) {
$(this).parents("tr").remove(); //Inside the callback
});
}
});
現在我的問題是,如果我在回調函數中刪除該行並沒有從項目立即刪除該行。我必須關閉並再次打開儀表板才能看到結果。
$(".del").live({
click: function() {
$.post("/Home/DeleteTemplate", {
name: $(this).parent().siblings("td:first").children("a").html()
});
$(this).parents("tr").remove(); //Outside the callback
}
});
這裏有什麼問題:
但如果我刪除回調函數的外部進入然後在同一時間刪除?
奈斯利發現那裏。 + 1 – Anand
@Anand:謝謝兄弟:) – Sarfraz
在數據中將'$(this)'改爲'that'' – 2012-06-19 11:28:33