Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<div id="pwdModal" class="white-popup mfp-with-anim mfp-hide">      
               <div id="ForgotPassDiv">
                  <h3 class="text-center">Forgot / Change Password</h3>
                          <div class="text-center">
                                    <div class="panel-body">
                                        <fieldset>
                                            <div class="form-group">
                                                <input class="form-control input-lg" placeholder="E-mail Address" id="txtForgotPassEmail" name="email" type="email"/>
                                            </div>
                                            <input class="btn btn-lg btn-primary btn-block" value="Send My Password" id="btnForgotPass" type="submit"/>
                                            <lable>New password will be sent to your official Email-id</lable>
                                        </fieldset>
                                    </div>
                                </div>
                                </div>

                        <div id="ChangePassDiv" style="display: none">
                            <h3 class="text-center">Change Password</h3>
                                <div class="text-center">        
                            <div class="panel-body">
                                <fieldset>
                                    <div class="form-group">
                                        <input class="form-control input-lg" placeholder="Enter your 4 digit OTP" id="txtChangePassOTP" name="OTP" type="password"/>
                                        <input class="form-control input-lg" placeholder="Enter your new password" id="txtNewPass" name="NewPass" type="password"/>
                                        <input class="form-control input-lg" placeholder="Re-type your new password" id="txtConfirmPass" name="ConfirmPass" type="password"/>
                                    </div>
                                    <input class="btn btn-lg btn-primary btn-block" value="Done" id="btnChangePass" type="submit"/>
                                </fieldset>
                            </div>
                        </div>
                        </div>
</div>




This is the pop up for change Password ,
I am trying to call this popup on AjaxSuccess funtion


$("#btnLogin").click(function () {
      debugger;
          var uName = $("#txtUserName").val();
          var pass = $("#txtPassword").val();
          var UserType= @Html.Raw(Json.Encode(ViewBag.Usertype));

          if (uName == '' || pass == '') {
              alert("please enter required Fields.")
          }
          else {
           debugger;

              $.ajax({
              type: "POST",
              url: "/MainIndex/ValidateUser",
              dataType: "json",
              data: { "userName": uName, "password": pass },

              success: function (info) {




                                        if(info=="1")
                                          {




                                         var url = "/Latest/LatestReport";
                                          window.location.href = url;
                                          }

                                         else if(info=="5")
                                          {
                                          var url = "/Latest/LatestReport";
                                          window.location.href = url;
                                          }
                                          else if(info=="4")
                                          {
                                          var url = "/PrintedReport/PrintedReportMain";
                                          window.location.href = url;
                                          }
                                          else if(info=="6")
                                          {
                                         // var url = "/Events/InnerConference";
                                          var url = "/NewConference/iifl_conference";
                                          window.location.href = url;
                                          }
                                          else if(info=="7")
                                          {
                                          var url = "/AboutUs/ResearchTeam";
                                          window.location.href = url;
                                          }
                                          else if(info=="8")
                                          {
                                          var url = "/AboutUs/IIFLTeam";
                                          window.location.href = url;
                                          }
                                          else if(info=="9")
                                          {
                                          var url = "/AboutUs/SalesTradingTeam";
                                          window.location.href = url;
                                          }
                                          else if(info=="10")
                                          {
                                          var url = "/AboutUs/IBTeam";
                                          window.location.href = url;
                                          }
                                          else if(info=="11")
                                          {
                                          var url = "/AboutUs/SettlementAndOp";
                                          window.location.href = url;
                                          }
                                          else if(info=="12")
                                          {
                                          var url = "/AboutUs/Leadership";
                                          window.location.href = url;
                                          }
                                          else
                                          {

                                          alert("Please Enter Valid Email ID And Password")
                                          $("#txtUserName").val("");
                                          $("#txtPassword").val("");
                                          }
                                     }
                  });
            }
      });





On this Function I am trying to call the Popup div .. but it not calling the popup.. But directly loading the page

What I have tried:

  $("#btnLogin").click(function () {
        debugger;
            var uName = $("#txtUserName").val();
            var pass = $("#txtPassword").val();
            var UserType= @Html.Raw(Json.Encode(ViewBag.Usertype));

            if (uName == '' || pass == '') {
                alert("please enter required Fields.")
            }
            else {
             debugger;

                $.ajax({
                type: "POST",
                url: "/MainIndex/ValidateUser",
                dataType: "json",
                data: { "userName": uName, "password": pass },
               
                success: function (info) {
//                var model = @Html.Raw(Json.Encode(ViewBag.Usertype)); 
//               
//    alert("Text is: " + model.Text);



                                          
                                          if(info=="1")
                                            {
                                                                                  document.getElementById("  pwdModal").style.display;
                                      
                                        $("#pwdModal").show();
                                             alert("Hello");
                                          $("#pwdModal").removeClass("hide");
//                                             ChangePassword();
//                                            
                                           
//                                            var url = "/Latest/LatestReport"; 
//                                            window.location.href = url; 
//                                            var url = "/Events/InnerConference"; 
//                                            window.location.href = url; 
                                            }
                                            
                                           else if(info=="5")
                                            {
                                            var url = "/Latest/LatestReport"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="4")
                                            {
                                            var url = "/PrintedReport/PrintedReportMain"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="6")
                                            {
                                           // var url = "/Events/InnerConference"; 
                                            var url = "/NewConference/iifl_conference"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="7")
                                            {
                                            var url = "/AboutUs/ResearchTeam"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="8")
                                            {
                                            var url = "/AboutUs/IIFLTeam"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="9")
                                            {
                                            var url = "/AboutUs/SalesTradingTeam"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="10")
                                            {
                                            var url = "/AboutUs/IBTeam"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="11")
                                            {
                                            var url = "/AboutUs/SettlementAndOp"; 
                                            window.location.href = url; 
                                            }
                                            else if(info=="12")
                                            {
                                            var url = "/AboutUs/Leadership"; 
                                            window.location.href = url; 
                                            }
                                            else
                                            {
                                           
                                            alert("Please Enter Valid Email ID And Password")
                                            $("#txtUserName").val("");
                                            $("#txtPassword").val("");
                                            }
                                       }
                    });
              }
        });



It only execute the info==1 condition.. since it has been defined from the server side
hence inside the "info=1"

I tried to
if(info=="1")
{
$("#pwdmodol").show();

}

But the popup is not coming
Posted
Updated 22-Aug-17 5:46am
v2

1 solution

Hi,
You can start with replacing all those else if with a switch case statement...still the idea why you're doing that is not clear

debugger;
not sure why you need this?

alert("Please Enter Valid Email ID And Password")
might better be returned from server ex: info.ErrorMessage

Normally on returning a json object, would access fields (can be simple fields, nested objects, arrays) ex: info.SomeProperty
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900