如何只在收到服务器的回复消息后显示DIV
How to show DIV only after receiving reply message from server?
我只想在从服务器获得响应后显示特定的div。
我想做的是,为我的用户提供一个密码恢复功能。我得到了他们注册的电子邮件ID,然后我用我的数据库进行了检查。如果它存在于我的数据库中,我会在div中发回一条消息,说明密码已发送到您的邮件ID。如果它是未注册的电子邮件ID,我会发送另一条消息说明电子邮件ID未注册。
这是我的两个潜水器:
DIV获取我的用户电子邮件ID
<div id="fgpass" >
<div id="newpass">
<div style="position: absolute;top: 10%;left: 10%;">
<center><h2>PASSWORD RECOVERY</h2></center>
<h4> Enter Your Registered</h4>
<h4>E-Mail Address :</h4>
<f:view>
<h:form>
<center>
<h:inputText id="cmailid" required="true" value="#{forgotPass.mailid}"/>
<h:commandButton value="Submit" action="#{forgotPass.fpass}">
</h:commandButton>
</center>
</div>
</div>
</h:form>
</div>
</div>
DIV显示服务器响应消息
<div id="msg" onclick="$('#msg').hide();">
<div style="position: absolute;top: 20%;left: 2%;">
<span style="font-size: medium;">
<h:outputLabel value="#{forgotPass.finalresult}"/>
</span>
</div>
</div>
我的CSS
#fgpass {
position: absolute;
left: 65%;
top: 4%;
border-color: #009900;
border-width: 3px;
border-radius: inherit;
z-index: 800;
}
#newpass{
position: absolute;
z-index: 1000;
height:160px;
width: 250px;
color: midnightblue;
visibility: hidden;
background-color: lavender;
-moz-border-radius: 8px;
border-radius: 8px;
border-width: 3px;
border-color:#444;
}
#msg {
z-index: 5000;
width:160px;
height: 150px;
-moz-border-radius: 8px;
border-radius: 8px;
border-width: 3px;
border-color:#444;
position: absolute;
left: 85%;
top:3%;
cursor: pointer;
background-color: navajowhite;
}
我的问题是,每当页面加载或重新加载时,msgDIV总是在屏幕上可见。我希望只有当它从我的服务器得到响应时,它才可见。有没有JQUERY或JAVASCRIPT或简单的CSS方法可以做到这一点?
当页面加载时,您需要隐藏div。向#msg
添加一个额外的样式可以实现
#msg
{
display: none;
}
如果您使用AAJAX从服务器获取响应,那么您可以使用以下代码
$("#msg").show();
在ajax请求的成功回调函数中。jQuery AJAX
使用jquery函数可以
$(document).ready(function(){
$("#msg").hide();
// later after ajax?
$.ajax(url).success (function(data) {
$("#msg").show();
return false;
});
});
<form method='post' action='#'>
<input type='text' name='email' placeholder="person@example.com">
<input type='submit' name="send" value='submit'>
</form>
<?php
//connect you database here
//after user submits the email check if the email exits
$sql = 'select * from yourtable where email='.$_POST['email'];
$res = mysql_query($sql);
if(mysql_count_rows($res)==1){
?>
<script>
var unhide_div = document.getElementById('mydiv');
unhide_div.style.visibility = 'visible';
</script>
<?php
}else{
die('Email verification failed!!!');
}
?>
如果检查了电子邮件,您的邮件将显示在此处!!
相关文章:
- Ajax聊天消息重复而不仅仅是更新
- 如果localstorage为空,则显示欢迎消息
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 离开页面时弹出消息
- 有没有一种方法可以在控制台关闭的情况下让console.log()在IE中记录消息
- 消息显示之外的淘汰验证
- 选项卡侦听器未被来自后台脚本的消息激活
- jQuery在输入下验证post错误消息
- Scipt未在选定选项卡中执行以发送和接收消息
- 检查xmlhttprequest问题的消息
- AngularJs对ng消息的自定义替换
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- 当用户按下回车键时,自动在text区域/text中插入消息
- 如果消息框答案为YES,则用Javascript填写表单
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- 如何只在收到服务器的回复消息后显示DIV
- 通过FB API回复页面时,消息为空
- Twilio API -从传入的文本消息中存储回复
- 不完全回复来自服务器的警告消息用ie8浏览器显示
- 编辑回复消息(评论)的讨论- SharePoint在线JavaScript