1

i have problem with my Ajax request.

when i am login with Ajax request it's like /Employee/Login with POST to controller it's working fine.

but return response is JSON type and not properly redirect to home page.

here is my Ajax Function

function Login() {

ShowProgressImage();

// var parameteres = $("#frmAdminLogin").serialize();

var parameteres = {
    "UserName": $("#UserName").val(),
    "Password": $("#Password").val(),
    "RememberMe": $("#RememberMe").is(":checked")
};

$.ajax({
    url: "/Employee/Login/",
    type: "POST",
    data: JSON.stringify({ "objAdminLoginViewModel": parameteres }),
    cache: false,
    contentType: "application/json; charset=utf-8",
    success: function (result) {
        if (result.ResponseCode == 1) {
            window.location = "/Product/Index/?filterby=recent";
        }
        HideProgressImage();
    },
    error: function (jqXHR, textStatus, errorThrown) {
        HideProgressImage();
    }
    //complete: function () {
    //    window.location.href = "/Product/Index/?filterby=recent";
    //}
});

}

i have attached error image below

Click Here to Show error image

So please suggest me actually where i am doing wrong.

Thanks in advance.

2 Answers2

0

To avoid this warning, do not use:

async: false

in any of your $.ajax() calls. This is the only feature of XMLHttpRequest that's deprecated.

The default is async: true, so if you never use this option at all, your code should be safe if the feature is ever really removed (it probably won't be -- it may be removed from the standards, but I'll bet browsers will continue to support it for many years).

madalinivascu
  • 32,064
  • 4
  • 39
  • 55
0

Your code does not seems to be causing the warning, becuse there is not a async: false sentence.

and actually the line :

window.location = "/Product/Index/?filterby=recent"

it does not match the url in the image. "localhost:5435" Maybe you are omitting the code that actually causes the warning

in fact the code that is causing the warning is using the option "XMLHttpRequest.withCredentials" another reason to believe that is not the code that you're showing.