Bug Tracker

Ticket #2871 (closed enhancement: fixed)

Opened 6 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

jquery-nightly.js Download (97.3 KB) - added by the7erm 6 years ago.
nightly build from 2008-05-15 with mda fix.
mda.php Download (2.7 KB) - added by the7erm 6 years ago.
php script used to toggle between the solution and the problem.

Change History

Changed 6 years ago by the7erm

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

Changed 6 years ago by the7erm

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

comment:1 Changed 6 years ago by flesler

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.

comment:2 Changed 6 years ago by ygirouard

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];
}

comment:3 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

Implemented via the ajax traditional property.

Note: See TracTickets for help on using tickets.