<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ajax测试</title>
<script src="js/jquery-2.1.4.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
span{font-family: sans-serif;font-size: 16px;padding: 10px 20px;}
button{width: 80px;height: 30px;line-height: 30px;background-color: burlywood;font-size: 16px;outline: none;border: none;margin-left: 30px;margin-top: 20px;}
#sub{text-indent: 2rem;margin-top: 20px;font-family: "楷体"}
</style>
</head>
<body>
<h1>nodeJs环境下,ajax请求测试</h1>
<span>姓 名:</span><input type="text" name="name" /><br />
<span>密 码:</span><input type="password" name="paw" /><br />
<span>性 别:</span><input type="radio" name="sex" value="0" /><i>男</i><input type="radio" name="sex" value="1" /><i>女</i><br />
<button id="btn">提交</button>
<div id="sub">
</div>
<script type="text/javascript">
$('#btn').click(function(event) {
$.ajax({
url: '/todata',
type: 'get',
dataType: 'json',
data: {name: $("input[type=text]").val(),paw: $("input[name=paw]").val(),sex: $("input[type=radio]:checked").val()}
})
.done(function(data) {
var jsons = JSON.stringify(data);
$('#sub').html("返回结果是:"+jsons);
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
});
</script>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
nodeJs服务访问兼容.zip (4个子文件)
ajax.html 1KB
server.js 240B
js
jquery-2.1.4.min.js 82KB
router.js 1KB
共 4 条
- 1
资源评论
薪往之
- 粉丝: 8
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功