![](/img/trans.png)
[英]Delete A specific row from table using id and refresh the same table in background using Jquery Ajax php mysql
[英]delete table row using jQuery within ajax statement
我想从表中删除一行,但是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: ...
});
我认为this
并不能带来您所期望的价值。
尝试这个:
function fn_delete() {
$("a.delete").click(function () {
idProduct = $(this).parents("tr").find("td").eq(1).html();
var myRow = $(this).parents("tr");
$.ajax({
type: "POST",
url: "DeleteProduct",
data: { idProduct },
success: function () {
$(this).parents("tr").fadeOut("normal", function () {
myRow.remove();
});
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.