如何在jQuery的通过AJAX发送一个复选框组? [英] How to send a checkbox group via ajax in jquery?
本文介绍了如何在jQuery的通过AJAX发送一个复选框组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要通过AJAX jQuery中发送一组复选框(与其他一些数据也一样)。
I need to send a group of checkboxes (with some other data as well) via ajax in jquery.
我所做的迄今:
var arr = $('#somediv input[type="checkbox"]:checked').val() || [];
$.post("/somephpfile.php", {str: str, arr: arr}, function(data) {...
但我的问题是,ARR是从来没有一个数组。我需要的是把它作为海峡=数据和放大器发送; ARR = FOO和放大器; ARR =酒吧
But my problem is that the arr is never an array. What I need is to send it as ?str=data&arr=foo&arr=bar
我想这是一个很简单的问题,但因为我是很新的jQuery的我要问的利弊。 我应该怎么办呢?
I guess this is a very simple question, but since I am very new to jquery I'll ask the pros. How should I do it?
感谢你。
我的不好,这是PHP
推荐答案
您可能会寻找 .serialize 一>
一个更通用的解决办法是有一个表格的所有参数,然后对其进行序列化。
A more generic solution would be to have a form with all the parameters and then serialize it.
这篇关于如何在jQuery的通过AJAX发送一个复选框组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文