首页 > 解决方案 > 使用 jquery POST 方法向服务器发送登录请求

问题描述

我想登录这个网站:https ://kintai.jinjer.biz/sign_in 我使用 POST 方法将登录凭据发送到网站表单并请求登录作为响应。但是它不起作用。当我单击按钮时,我被重定向到登录页面。代码有问题吗?

<html>
<head>
<title> Approach to Login</title>
<script type="text/javascript" src="https://jinji.jinjer.biz/assets/templates/hr/js/jquery.min.js"></script>
<script async="" src="//wap.wovn.io/1.js"></script>

<script>
$(document).ready(function() {
    $("button").click(function(){
    $.post("https://kintai.jinjer.biz/sign_in",{

    company_code:"5709",
    email:"1234",
    password:"1234"
    },function (data) {

       window.open("https://kintai.jinjer.biz/staffs/top");
        });

    });

});

</script>

</head>

<body>
<button type= "submit"> Login </button>




</body>

</html>

标签: javascripthtmljqueryajax

解决方案


尝试添加阻止默认值。

$("button").click(function (e) {
    e.preventDefault();

    $.post("https://kintai.jinjer.biz/sign_in",{
        company_code:"5709",
        email:"1234",
        password:"1234"
    },function (data) {
        window.open("https://kintai.jinjer.biz/staffs/top");
    });
});

推荐阅读