1 Star 0 Fork 0

wangdongwei0129/wangdongwei

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
02-用Ajax提交数据.html 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
wangdongwei 提交于 2021-05-15 16:18 . 加入成功
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- form表单用来采集数据 -->
结论:enctype
<form>
<span>用户名</span>
<input type="text" name="uname">
<span>密码</span>
<input type="password" name="password">
<button>登录</button>
</form>
<script src="./js/jquery-1.12.4.min.js"></script>
<script>
$(function () {
$('form').on('submit',function (e) {
e.preventDefault()
const str = $(this).serialize()
$.post('http://www.liulongbin.top:3006/api/form',str,function (res) {
console.log(res);
})
// 以Ajax方式提交
// $.ajax({
// type:'POST',
// url:'http://www.liulongbin.top:3006/api/form',
// data:str,
// success:function (res) {
// console.log(res);
// }
// })
})
})
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangdongwei0129/wangdongwei.git
git@gitee.com:wangdongwei0129/wangdongwei.git
wangdongwei0129
wangdongwei
wangdongwei
master

搜索帮助