как получить ответ службы и переключить модалпоп с помощью asp. net 4.0 - PullRequest
0 голосов
/ 16 февраля 2020

У меня есть одна служба eb, которая отправляет otp с проверкой некоторых условий из базы данных. Вот мой код обслуживания:

[WebMethod]
    [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
    public string SendOTP(string username)
    {
        string Response = string.Empty;
        try
        {
            bool _isOTP = false;
            LoginRequest login = new LoginRequest();
            login.UserName = SiteUser.Current().UserName.ToString();
            login.Password =  SiteUser.Current().Password.ToString();

            LoginLibrary.Business.SMSUser.VLUser objUser = SiteUser.AuthenticateUser(login);

            if (objUser != null)
            {
                _isOTP = objUser.isOTP;
                if (_isOTP == true)
                {
                    SiteUser.GenerateUserAuthentication(username);
                    Response = "Success";
                }
                else
                {
                    Response = "NoOTP";
                }
            }
        }
        catch (Exception ex)
        {
            Response = "Error in Sending OTP to : " + username + CommonMethods.GetErrorMessage(ex, "OTPSend");
        }
    RESPONSE:
        if (!string.IsNullOrWhiteSpace(Response))
            AppGlobal.Logger.WriteToErrorLogFile(Response);
        return Response;
    } 

с его ответом я просто делаю y модальное всплывающее окно скрытия или показа:

 function SendOTP() {

            $.ajax({
                url: "../Service/UserManage.asmx/SendOTP",
                type: "POST",
                dataType: "json",
                data: '{username:"' + $('#<%=hfusername.ClientID %>').val()  +'" }',
                contentType: "application/json; charset=utf-8",
                async: false,
                success: function(response)
                {
                    if( response == 'NoOTP')
                        $('#myModalOTP').modal('hide')
                    else 
                        $('#myModalOTP').modal('show')
                },
                failure: function (response) {
                    toastr["error"](response.d, "FAIL");
                },
                error: function (response) {
                    toastr["error"](response.d, "ERROR");
                }
            });
        }

но мое модальное всплывающее окно всегда показывает ...... ........... что здесь не так, пожалуйста, помогите мне ..................

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...