在ajax请求之后,我在类为echo
的div中发送了响应。
这是我的html结构:
<div class="container-fluid">
<div class="fixed-header>
<div class="echo"></div>
----
ajax看起来像这样:
$.ajax({
url: "",
type: "POST",
data: new FormData(this),
contentType: false,
processData: false,
success: function(response) {
$(".echo").html(response);
},
});
提交后在DOM中查看时,我看到所有head
文件(如样式表和脚本)都已重新加载。那正常吗?应该是这样吗?见下图
添加了Php代码:
if($_POST['deletefile']) {
// if is directory -> remove dir
if(is_dir($_POST['deletefile'])){
removeDirectory($_POST['deletefile']);
include('includes/delete.php'); // echo
exit;
}
// else (must be a file) -> unlink file
else {
unlink($_POST['deletefile']);
include('includes/delete.php'); // echo
exit;
}
return false;
}