页面html
<!DOCTYPE html>
<html>
<body>
<form method="post">
<input name="item" type="checkbox" value="1" />
<input name="item" type="checkbox" value="2" />
<button>提交</button>
<a id="click" href="javascript:void(0)">ajax 请求(提交多个checkbox的值)</a>
</form>
</body>
</html>
juqery ajax请求示例
$(function(){
$('#click').click(function(){
var items2 = { 'item': [] };
$("input[name='item']:checked").each(function(i, n){
items2['item'].push(n.value);
});
//alert(items2);
$.ajax({
url: '/test/multiple',
type: 'delete',
data: items2,
});
});
});
tornado 处理参数
def delete(self):
items = self.get_arguments('item[]')
self.write(str(items))
tornado返回数据
[1, 2]
网友评论