我写了一个 javascript 函数,它发布一个表单并重定向到主页。我使用 window.location.replace 进入主页。但该函数不是替换 url,而是将 url 附加到当前 url 前面。有什么问题?
$('#submit_fourth').click(function () {
// send data to server to save in table dbo.aspnet_Users =================================================
var firstname = $("#firstname").val();
var lastname = $("#lastname").val();
var username = $("#username").val();
var password = $("#password").val();
var email = $("#email").val();
$.post("/Account/Register", { FirstName: firstname, LastName: lastname, UserName: username, Password: password, ConfirmPassword: password, Email: email });
//send information to server
alert('Congratulations! Your account has been sucessfully created.');
//get back to the login screen
window.location.replace("dgsmart/Central/Login");
当前 url 是 184.180.25.240/dgsmart/account/register 后注册按钮点击它变成 184.180.25.240/dgsmart/account/central/login 我想要 url lyk 这个 184.180.25.240/dgsmart/central/login