javascript - 使用 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>
解决方案
尝试添加阻止默认值。
$("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");
});
});
推荐阅读
- typescript - 猴子补丁 react-native Text 组件与 TypeScript
- dart - Dart 的分析器和 linter 有什么区别?
- python - 查找导出的 csv 的路径
- for-loop - 简单的 JS for 循环删除 Google 表格中的表格不循环
- c# - Razor 中的 Html.DisplayNameFor List 与 IEnumerable
- powershell - Azure Pipelines Powershell 脚本中的“找不到类型”错误
- ios - 如何在 SwiftUI 中有条件地设置视图转换?
- c++ - 是否可以在 C++ 中为指针提供参数,这是什么意思?
- c++ - C++:在一个循环中迭代一个列表和一个 unordered_map
- java - 片段不可滚动