I have added a loader on my phonegap app on login button it works. but when Some alert occurs like password mismatch or invalid user, The loader doesn't stops. I have added my loader on html page, and want to stop at my Authentication js page in which alerts box are there in my html page to hide on next page I am using
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#loading').hide();
});
</script>
how to hide my loader on js page alerts
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!");
}
you can make the following change to your function to make it work:
function ConnectionEstablished(ResponseData) {
if (ResponseData != "")
{
//alert("resp"+ResponseData)
AuthenticationSuccess(ResponseData);
}
else
{
$('#loading').hide(); //hide the loader!
alert("Username or Password is incorrect!");
}
}
Try if it works!