I have this AJAX call:
$.ajax({
type: "post",
dataType: "json",
data: { "json": JSON.stringify(json) },
url: hostUrl,
success: function (data) {
if (data.status) {
window.location.href = data.redirect;
}
else {
alert(data.message);
}
},
error: function (err) {
console.log(err);
}
});
data.redirect
contains URL, which user should be redirected to, but unfortunately, it does nothing.
Can anybody tell me what is the issue?
I tried to redirect to other ASP controllers, or even www.google.com
, but nothing works.
This is JSON response:
{"status":true,"message":"successful authentication","redirect":"/Users"}
I am working with ASP.NET Core, I set breakpoint in Users
controller, to which I am redirecting. It was hit just once. After that one redirect, it stops to redirect to that page. But even if breakpoint was hit, it didn't redirect to returned view.
It's like just getting refreshed
EDIT:
HTML, which appeared to be important:
<form method="post">
Login:
<input name="loginName" type="text" /> <br/>
Password:
<input name="passwordInput" type="password" /><br/>
<button id="authBtn" onclick="handleLogin()" value="Get message"></button>
</form>