[英]Remove element after ajax call
I have a div element that is being the after the modal close which makes my screen unresponsive.我有一个 div 元素在模态关闭之后,这使我的屏幕无响应。
<div class="modal-backdrop fade show"></div>
When I remove the attribute from console through below command it works.当我通过以下命令从控制台删除属性时,它可以工作。
$( ".modal-backdrop" ).remove();
But when I add this on success of ajax call it doesn't.但是当我在 ajax 调用成功时添加它时,它没有。 Shall I handle this differently?
我应该以不同的方式处理这个吗?
Below is the ajax call:下面是ajax调用:
function saveParty(){
var hasError = validateParty();
if(!hasError){
var data = loadPartyDetails();
var objectID = $("#objectID").val();
$.ajax({
type : "POST",
contentType: "application/json",
url: "/saveDetails/" + objectID + "/",
data: JSON.stringify(data),
timeout : 100000,
success : function(result) {
$("#detailsPanel").html(result);
document.getElementById("successMsgParties").style.display="";
$('#successMsgParties').delay(5000).fadeOut('slow');
},
error : function(e) {
console.log("ERROR: ", e);
},
done : function(e) {
console.log("DONE");
}
});
}
I have putting remove line code in done and after ajax call completed.我已经将删除行代码完成并在 ajax 调用完成后。
Try to write this in success response:尝试在成功响应中写下这个:
$(".modal-backdrop" ).hide();
Or make html empty using empty()
:或者使用
empty()
使 html 为空:
$(".modal-backdrop" ).empty();
Or make html empty:或者让 html 为空:
$(".modal-backdrop" ).html('');
在成功部分写这个
$(".modal-backdrop" ).remove();
我必须在多个地方使用下面的内容才能使其工作。
$(".modal-backdrop" ).remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.