繁体   English   中英

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

[英]How to stop loader when alert box opens

我已经在我的phonegap应用程序的登录按钮上添加了一个加载程序,它可以正常工作。 但是当出现某些警报(例如密码不匹配或用户无效)时,加载程序不会停止。 我已在html页面上添加了我的加载程序,并想在我的html页面中存在警报框的Authentication js页面处停止,以隐藏在我正在使用的下一页上

<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!");
}

您可以对函数进行以下更改以使其起作用:

function ConnectionEstablished(ResponseData) {
    if (ResponseData != "")
    {
        //alert("resp"+ResponseData)
        AuthenticationSuccess(ResponseData);
    }
    else
    {
        $('#loading').hide(); //hide the loader!
        alert("Username or Password is incorrect!");
    }
}

尝试是否有效!

暂无
暂无

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

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