jquery中的 ajax 以及map遍历
2024-09-14 17:10:29
1.语法
$.ajax{
type:'get',//类型 有get post
url:'',//路径
data:{name:$('#ma').val(),nameq:$('#maq').val()},
dataType="json",
success:function(data){alert("成功了")}
}
2.获取data数据的方法
如果这样写的话会写吐血的name:$('#ma').val(),nameq:$('#maq').val()
可以用map方法
var map=$(':checkbox').map(function() {
return ($(this).attr("id")+'='+$(this).val());
}).get().join('&');
alert(map)
<form method="post" action="">
<fieldset>
<div>
<label for="two">2</label>
<input type="checkbox" value="2" id="two" name="number[]">
</div>
<div>
<label for="four">4</label>
<input type="checkbox" value="4" id="four" name="number[]">
</div>
<div>
<label for="six">6</label>
<input type="checkbox" value="6" id="six" name="number[]">
</div>
<div>
<label for="eight">8</label>
<input type="checkbox" value="8" id="eight" name="number[]">
</div>
</fieldset>
</form> </body>
<script>
var map=$(':checkbox').map(function() {
return ($(this).attr("id")+'='+$(this).val());
}).get().join('&');
alert(map)
</script>
最新文章
- java是值传递还是引用传递
- Asp.net Mvc 使用EF6 code first 方式连接MySQL总结
- 纯css3实现旋转的太极图
- SQL年月日方面的查询信息
- 通过ajax访问aspx的CodeBehind中的方法
- centOS 6.x 版本安装 node.js 4.x 以上版本的方法
- php.ini 配置文件的深入解析
- Pearls DP
- cmakelists 语法学习
- Letter Combinations of a Phone Number 解答
- SQL Server内存
- 使用git提交到github,每次都要输入用户名和密码的解决方法
- Android NFC技术(三)——初次开发Android NFC你须知道NdefMessage和NdefRecord
- 修改vue element Transfer 穿梭框里内容区的宽度
- Siamese Neural Networks for One-shot Image Recognition
- 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置
- 【Matplotlib】数据可视化实例分析
- asp.net 项目目录说明
- Failed to register: Error: fabric-ca request register failed with errors [[{";code";:0,";message";:";No identity type provided. Please provide identity type";}]]解决方案
- [转]IOS 崩溃日志分析