i have written a javascript function thats posts a form and redirect to home page . Im using window.location.replace to get to home page. but instead of replacing the url the function is appending the url in front of current url. Whats the problem?
$('#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");
current url is 184.180.25.240/dgsmart/account/register after register button click it becomes 184.180.25.240/dgsmart/account/central/login i want url lyk this 184.180.25.240/dgsmart/central/login
I assume you are using a form onsubmit event to call some function, if so you have to prevent the default behavior by return false; (for example)
window.location.replace("absolute-address"); /*window.location.replace('http://example.com/#' + initialPage); */
return false; //prevent the default behavior of the submit event
You can also using this code to set your ideal url...
<script>
location.href='RegisterNew.php';
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.