So would you recommend doing something like....

data = $('input:checkbox[name=ckdOrd[]]:checked').serialize()

...in the ajax?

On Nov 25 2009, 12:41 am, "Bryan Garaventa" <goo...@gutterstar.net>
wrote:
> I'd recommend serializing the array into a string, then reverse the
> serialization on the server side using PHP. This way, you can pass the array
> string within a url.
> Hope this helps,
> Bryan Garaventa
>
>
>
> ----- Original Message -----
> From: "Bonji" <benho...@googlemail.com>
> To: "jQuery (English)" <jquery-en@googlegroups.com>
> Sent: Tuesday, November 24, 2009 2:52 PM
> Subject: [jQuery] Sumbit multiple checkboxes via ajax to php script using
>
> jQuery
>
> > Hi,
> > I am working on improvements for a web app.
> > It currently submits checkboxes to a php script for processing by
> > simply submitting the form naturally. However i require this action
> > using a ajax post to save bandwidth etc. and im struggling to work out
> > how to do this.
>
> > Im familiar with normal ajax posts using jquery but here i need to
> > post an array.
>
> > Simplified a little this is what i have.
>
> > <input type="checkbox" name="ckdOrd[]" value="1" id="order_1"  />
> > <input type="checkbox" name="ckdOrd[]" value="2" id="order_2"  />
> > <input type="checkbox" name="ckdOrd[]" value="3" id="order_3"  />
> > <input type="checkbox" name="ckdOrd[]" value="4" id="order_4"  />
>
> > It used to build an array ckdOrd[] and post to a php script with a
> > loop for processing. It needs to post the order numbers as an array
> > for processing.
>
> > Is there a way to simply create the same post using ajax jQuery?
>
> > I would prefer this as that would mean i dont have to make major
> > changes to the php script.
>
> > the php simply does something like this
>
> > //get posted array
> > $ckdOrd=$_REQUEST['ckdOrd'];
>
> > foreach($ckdOrd as $key => $ord_no){
> >   //update mysql here
> > }
>
> > I have seen other posts but they all seem to be cluttered and
> > unhelpful.
>
> > Is it correct to avoid the name attribute and simple find each checked
> > checkbox using jquery? or am i going down the wrong path.

Reply via email to