[英]How to hide Div tag without page refresh
I have a page where i add,edit and delete menus.For add and edit I have a separate page.When i add or edit menus,i come on the main page where i display the menus,so i print messages as "menu added" or "menu edited".But when i delete the menu,my page does not get refreshed,because i have written the delete code on the same page sing ajax function as follows: 我有一个在其中添加,编辑和删除菜单的页面。对于添加和编辑,我有一个单独的页面。当我添加或编辑菜单时,我出现在显示菜单的主页面上,因此我将消息打印为“添加菜单” ”或“菜单编辑”。但是,当我删除菜单时,我的页面没有刷新,因为我在同一页面上使用ajax函数编写了删除代码,如下所示:
$.ajax(
{
type: "POST",
url: "delete_menu.php",
data: data,
cache: false,
success: function()
{
parent.fadeOut('slow', function() {$(this).remove();});
document.getElementById('showDiv').style.display = '';
}
}
The page does not get refreshed,so the div containing messages like "menus added or edited" does not get hide.I have given id to Div as showDiv. 页面不会刷新,因此包含诸如“添加或编辑菜单”之类的消息的div不会被隐藏。我已将id赋予showDiv。 So can anyone help me to solve this problem.Also when i delete,can anyone tell me how do i display message as "menu deleted" in ajax without page refresh.Thanks in advance.
所以任何人都可以帮助我解决这个问题。此外,当我删除时,谁能告诉我如何在ajax中将消息显示为“菜单已删除”而不进行页面刷新。
document.getElementById('showDiv').style.display = 'none';
Since you have referenced jQuery, I would use jQuery syntax instead of Plain Old JavaScript, to keep the syntax cleen. 由于您已引用jQuery,因此我将使用jQuery语法而不是Plain Old JavaScript来保留语法。
$("#showDiv").hide();
If you are not going to show the div again on the page, you could use this: 如果您不想在页面上再次显示div,则可以使用以下方法:
$("#showDiv").remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.