How do I redirect my current window to a new one through an ajax call?
Ajax call code:
function autenticarme() {
var nick = $(".txtNick").val();
var pass = $(".txtPass").val();
$.ajax({
type: "POST",
url: "login.aspx/conectarBD",
dataType: "text",
async: false,
data: "{ nick: '" + nick + "',password: '" + pass + "' }",
contentType: "application/json; charset=utf-8",
success: function (data) {
window.location = data."http://localhost:52403/WebSite2/CRUD.aspx";
}, error: function (xhr, status, error) {
alert("Error");
}
});
}
Now use the following methods within succes:
location.replace("CRUD.aspx");
window.location.href = 'CRUD.aspx';
window.location.assign("CRUD.aspx");
window.open('@Url.Action("CRUD", "ReportExecution")');
None of them takes any action on me, just that the page I'm on does not move.
Update
With this line of code in succes, you redirect me:
window.open('CRUD.aspx')
But I opened the window in a new tab, I would like to know how I close the current window if a new one opens.