仅序列化选中的复选框并通过 $.get 发送它们
已经这样做有一段时间了,似乎无法让它工作,我要么需要通过 POST 或 GET 来完成,但是我一直陷入困境,我当前的代码是
<script>
$('#RequestSupport2').submit(function() {
var values = {};
$("#RequestSupport2 :checked").each(function(key, value) {
// alert("key"+key+"value = " + $(this).val());
values[this.name] = $(this).val();
});
var values2 = $(values).serialize();
$.post("URL", { name: values2}, function(data){
$("#result").html(data);
});
return false;
});
</script>
因为 GET 不起作用是否太多复选框和字符串变得太长,任何人都可以帮助使其与 GET 或 POST 一起使用吗?并仅通过已检查的元素进行发布,
提前致谢!
have been at this for a while now, and can't seem to get it to work, I either need to do it via POST or GET, however I keep getting stuck, current code I have is
<script>
$('#RequestSupport2').submit(function() {
var values = {};
$("#RequestSupport2 :checked").each(function(key, value) {
// alert("key"+key+"value = " + $(this).val());
values[this.name] = $(this).val();
});
var values2 = $(values).serialize();
$.post("URL", { name: values2}, function(data){
$("#result").html(data);
});
return false;
});
</script>
As GET didn't work as there were too many check boxes and string just became too long, anyone could help getting this to work with either GET or POST? and post through only checked elements,
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试删除空格
#RequestSupport2
和:checked
Try removing the space
#RequestSupport2
and:checked