Skip to main content

Bug Tracker

Side navigation

#2871 closed enhancement (fixed)

Opened May 15, 2008 08:17AM UTC

Closed June 15, 2010 02:26AM UTC

Multi dimentional array support for ajax posting.

Reported by: the7erm Owned by:
Priority: major Milestone: 1.2.4
Component: ajax Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:
Description

I don't know if you want to add this or not, but it's there if you want it.

I do a lot of multi dimensional work, and figured it'd be nice to have this ability in jquery.

http://the-erm.com/~erm/player2/mda.php

Attachments (2)
  • jquery-nightly.js (97.3 KB) - added by the7erm May 15, 2008 08:32AM UTC.

    nightly build from 2008-05-15 with mda fix.

  • mda.php (2.7 KB) - added by the7erm May 15, 2008 08:33AM UTC.

    php script used to toggle between the solution and the problem.

Change History (3)

Changed May 15, 2008 01:01PM UTC by flesler comment:1

Hi the7erm

We rejected a similar feature, although we had all ready to commit, because of a cite on a spec on webforms.

Check #2726. I'll close this soon, reply if you have something to add.

Changed June 10, 2008 08:19PM UTC by ygirouard comment:2

I'm not sure if this works with server-side languages other than php, but if you pass key/value pairs where the key has a [something] appended to its name, php will convert it into an array where "something" becomes an index.

So, if you want to pass a multi-dimensional array when posting, you could do something like this:

Let's say you want to pass something like this:

var options = {
 "a":"1",
 "b":{"I":"1", "II":"2"},
}

So that you receive this on server-side (in php in my case):

array(
 "a"=>"1",
 "b"=>array(
  "I"=>"1",
  "II"=>"2"
 )
)

You could pass this in your post:

var options = {
 "a":"1",
 "b[I]":"1",
 "b[II]":"2"
}

It may need a bit of manual parsing in javascript if you had a pre-constructed object you want to pass, but that's easy enough to do using the "for (key in object) {}" method...

i.e.

var options = {
 "a":"1",
 "b":{"I":"1", "II":"2"},
}

var b = options.b;
delete(options.b);
for (i in b) {
 options["b[" + i + "]"] = b[i];
}

Changed June 15, 2010 02:26AM UTC by dmethvin comment:3

resolution: → fixed
status: newclosed

Implemented via the ajax

traditional
property.