ajax成功重新加载div内容不起作用
有很多问题,但没有答案似乎很容易。
There are many questions on this but no answer seems to be easy working.
我有一个< form>
每行都有删除图标。现在 .on('click',functoin()..
我有这样的ajax请求:
I have a <form>
with delete icons on every row. Now .on('click',functoin()..
I have an ajax request like this:
$.ajax({
type:"POST",
url:"/update_rows.php",
data:"delete_id="+$(this).attr("row"),
success:function(data) {
if(data) {
//window.location.reload(true);
//alert(data);
$(".refresh-after-ajax").load("/cms/modules/mod11/inc/modinclude_admin.php .refresh-after-ajax");
} else {
//window.location.reload(true);
}
}
});
这有效, update_rows.php
如下所示:
<?php
require_once($_SERVER["DOCUMENT_ROOT"].'/cms/inc/config.inc.php');
global $navid,$DB_PRE,$lang_cms;
$db=new DB();
$sql='Delete FROM '.$DB_PRE.'_mod_ref_pricing WHERE id='.intval($_POST['delete_id']);
$db->query($sql);
?>
现在我不想使用窗口。 location.reload(true);
因为我只想更新已删除行的容器。当你看到我尝试用 .load()
来重新加载那个< div />
但没有机会。 alert(data)
是空的,因为我没有从 update_rows.php
返回任何内容但是应该返回哪里刷新< div />
?
Now I don't want to use window.location.reload(true);
cause I just want to update that container where a row has been deleted. As you cann see I tried with .load()
to only reload that <div/>
but no chance. alert(data)
is empty because I'm not returning anything from update_rows.php
but what should I return there to refresh the <div/>
?
感谢您的建议!
OOOHHHHHH我在错误的地方写了 .load 现在它可以工作:
OOOHHHHHH I've written the .load()
at the wrong place now it works:
$.ajax({
type:"POST",
url:"/update_rows.php",
data:"delete_id="+$(this).attr("row"),
success:function(data) {
if(data) {
} else {
$(".refresh-after-ajax").load(window.location + " .refresh-after-ajax");
}
}
});
感谢您的帮助,$(this).remove()也是一个不错的解决方案
Thanks for the help, the $(this).remove() would also have been a nice solution