简体   繁体   English

警报框打开时如何停止加载程序

[英]How to stop loader when alert box opens

I have added a loader on my phonegap app on login button it works. 我已经在我的phonegap应用程序的登录按钮上添加了一个加载程序,它可以正常工作。 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 我已在html页面上添加了我的加载程序,并想在我的html页面中存在警报框的Authentication js页面处停止,以隐藏在我正在使用的下一页上

<script language="javascript" type="text/javascript">
    $(document).ready(function() {
    $('#loading').hide();
});

</script>

how to hide my loader on js page alerts 如何在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!");
}

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! 尝试是否有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM