我想从表中删除一行,但是ajax的成功部分没有执行。
function fn_delete() {
$("a.delete").click(function () {
idProduct = $(this).parents("tr").find("td").eq(1).html();
$.ajax({
type: "POST",
url: "DeleteProduct",
data: { idProduct },
success: function () {
$(this).parents("tr").fadeOut("normal", function () {
$(this).remove();
}
});
});
};
最佳答案
成功回调中的
this
不会与进行 ajax 调用的代码中的 this
相同,除非您显式设置 context
:
$.ajax({
context: this,
data: ...
});
关于javascript - 在 ajax 语句中使用 jQuery 删除表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46492207/