奇怪的重定向行为

时间:2019-08-26 20:43:45

标签: javascript jquery django django-templates

在不同的浏览器上,我的Django模板显示的行为不一致。

这是表格:

    <div class="login-form center">
        <div class="form-group">
            <input type="text" class="form-control login-field" value=""
                   placeholder="Enter your Worker-ID here" id="user-id">
            <label class="login-field-icon fui-user" for="user-id"></label>
        </div>
        <a id="btn-login" class="btn btn-primary btn-lg btn-block">Next</a>
    </div>

和相关的javascript:

    $(document).ready(function() {
        $('#btn-login').click(click_event);
    });

    function click_event() {
        let user_id = $('#user-id').val();
        if (!user_id) {
            alert("Please enter your username!")
        }
        else {
            $.post("/snli/api/auth_login/", {
                "username": user_id,
            }, login_callback);
        }
    }

    function login_callback(message) {
        // do more stuff 
        window.location.href = '/snli/human_annotations/'; // <-- the redirect 
    }
  • 在Chrome上,它被重定向到http://localhost:8000/snli/human_annotations/
  • 在Firefox上,它被重定向到http://localhost:8000/login/?next=/snli/human_annotations/,然后卡在“找不到页面”上。这是一个问题,因为我的重定向不起作用。

有什么想法导致这种差异? (以及如何解决?)

0 个答案:

没有答案
相关问题