如何使用jQuery重定向到另一个页面?

Arr*_*ron 37 jquery redirect

我有一个登录表单,我想用jQuery验证和重定向(如果用户名和密码是正确的),重定向不起作用.

这是我的代码:

$(document).ready(function() {
    $('#lc-login').click(function() {
        var username = $('#username').val();
        var pass = $('#pass').val();        

        if (testUser(username) === true && testPass(pass) === true) {            
            window.location.replace("http://www.domain.com/home.html");
        } else {
            alert('warning message');
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我试着更换一下window.location.replace,window.location.href但仍然没有.我应该说testUser和testPass工作正常,因为如果我添加一个简单的alert('the validation is ok!'),消息就出现在我的屏幕上.