Search code examples
jqueryasp.netauthenticationjquery-post

Jquery Post Not Calling Page


Good morning!

I have a user login page "/Account/Login.aspx" which uses a custom I've included an tag for the user to reset their password - <a href="javascript:ConfirmPasswordChange();">Forgot Password?</a>

My post doesn't call my page "/Account/LoginMethods.aspx" (No breakpoint firing), but instead returns the result as the entire content of the user login page "/Account/Login.aspx" html

<script language="javascript" type="text/javascript">
            function ConfirmPasswordChange() {
                $("#ConfiormPasswordReset").dialog({
                    modal: true,
                    autoOpen: false,
                    autoResize: true,
                    title: "Reset Password",
                    draggable: true,
                    buttons: {
                        'Cancel': function () {
                            $(this).dialog("close");
                        },
                        'Continue': function () {
                            SendNewPassword();
                        }
                    }
                }).dialog("open");
                $('#ConfiormPasswordReset').focus();
            }

            function SendNewPassword() {
                $.post("/Account/LoginMethods.aspx", { UserEmail: $("#UserName").val() },
                    function (result) {
                        alert(result);
                    });
                $('#ConfiormPasswordReset').dialog("close");
            }
    </script>

Any Idea of the possible problem?


Solution

  • It's likely that your LoginMethods.aspx page is rejecting the request, redirecting back to Login.aspx because you're lacking credentials. When you make an AJAX request, XmlHttpRequest transparently follows redirects, so it'll spit out whatever it finally ended up being redirected to.