簡體   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