问答详情
源自:1-5 使用post()方法以POST方式从服务器发送数据

点击登录按钮,用post方法成功获取到token后,怎么转到登陆界面

<form id="register" action="http://localhost:8000/api-token-auth/" method="post">

          <h2>欢迎登录</h2>

          <label for="name">Username</label><input type="text" id="name" name="name" />

          <label for="pwd">Password</label><input type="password" id="pwd" name="pwd" />

          <button onclick="login();return false">登录</button>

</form>

<script type="text/javascript">

function login(){

$.post("http://localhost:8000/api-token-auth/",{username: $("#name").val(),password: $("#pwd").val(),}, 

function(result) {console.log(result)})

}

</script>


提问者:程序小白zxcn 2019-05-09 20:21

个回答

  • xiaoma_0004
    2019-08-10 11:35:48

    重定向