我在登录按钮上的phonegap应用程序中添加了一个加载程序。但是当出现密码不匹配或用户无效的某些警报时,加载程序不会停止。我已经在html页面上添加了我的加载器,并希望停在我的身份验证js页面,其中我的html页面中的警报框隐藏在我正在使用的下一页上
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#loading').hide();
});
</script>
如何在js页面警报中隐藏我的加载器
if(Server == "" || UserName == "" || UserPass == "")
{
if(Server == "")
{
alert("Please enter server address");
}
if(UserName == "")
{
alert("Please enter User Name");
}
if(UserPass == "")
{
alert("Please enter Password");
}
}
else
{
strUrl="https://" + Server + ":1000";
//alert("Test"+strUrl);
sessionStorage.setItem("Server",Server);
window.localStorage.setItem("serUrl", strUrl);
window.localStorage.setItem("serUrl", strUrl);
window.localStorage.setItem("Server", Server);
strSerUrl="http://" + Server + ":8888/";
//alert(strSerUrl);
window.localStorage.setItem("ServerUrl", strSerUrl);
var DivId=sessionStorage.getItem('DivId');
DivId=window.localStorage.getItem("DivId")
// alert(DivId);
Identifier=Identifier+"_"+DivId;
//alert("Create Session1"+Identifier);
window.localStorage.setItem("Identifier", Identifier);
sessionStorage.setItem("Identifier",Identifier);
//alert("above create session")
services.CreateSession(Identifier, SystemID, UserName, UserPass, ConnectionEstablished, AuthenticationFailed);
}
}
function ConnectionEstablished(ResponseData) {
if (ResponseData != "")
{
//alert("resp"+ResponseData)
AuthenticationSuccess(ResponseData);
}
else
alert("Username or Password is incorrect!");
}
答案 0 :(得分:0)
您可以对您的功能进行以下更改以使其正常工作:
function ConnectionEstablished(ResponseData) {
if (ResponseData != "")
{
//alert("resp"+ResponseData)
AuthenticationSuccess(ResponseData);
}
else
{
$('#loading').hide(); //hide the loader!
alert("Username or Password is incorrect!");
}
}
尝试它是否有效!