2013-08-19 5 views
0

나는 폼을 게시하고 홈 페이지로 리다이렉트하는 자바 스크립트 함수를 작성했다. 메신저는 window.location.replace를 사용하여 홈페이지로 이동합니다. 대신 url을 바꾸는 대신에 함수는 현재 url 앞에 url을 추가합니다. 뭐가 문제 야?window.location.replace not working

$('#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 내가 URL이 184.180.25.240/dgsmart/central/을 LYK 원하는 등록 버튼 후 184.180.25.240/dgsmart/account/register 그것이 을 184.180.25.240/dgsmart/account/central/login된다 클릭입니다 로그인

답변

0

나는 당신이 false를 돌려서 디폴트 행동을 막아야 만한다면, 어떤 함수를 호출하기 위해 onsubmit 이벤트를 사용한다고 가정한다;

window.location.replace("absolute-address"); /*window.location.replace('http://example.com/#' + initialPage); */ 
return false; //prevent the default behavior of the submit event 
+0

을 이상적인 URL을 설정하려면이 코드를 사용하지만, 교체 할 수 있습니다. 그 사람이 upvote 또는 응답을 받아들이기를 기다리는 나중에 나중에 부분을 제거 할 수 –

+0

그것을 대체하는 대신 URL을 계속 추가 : |. 나는 window.loaction과 window.location.href를 시도했지만 성공하지 못했다. – rao

-1

(예) 당신은 또한() 나 때때로 그래서 그것을 언급 젊고 아름다운 여자를 ... 좋아

<script> 
    location.href='RegisterNew.php'; 
</script>