Skip to main content

Bug Tracker

Side navigation

#2726 closed enhancement (wontfix)

Opened April 21, 2008 04:41PM UTC

Closed May 14, 2008 10:29PM UTC

AJAX functions don't pass JSON with arrays properly

Reported by: lukebrookhart Owned by: flesler
Priority: minor Milestone: 1.2.4
Component: ajax Version: 1.2.3
Keywords: JSON arrays Cc:;
Blocked by: Blocking:

With all the AJAX functions (ie. .load, .post .get, etc) the JSON data that is sent to the server does not pass the array data properly. Due to the way arrays are passed to web servers, the names of the array variables need to be concatenated with "[]" to signal to the server that there is more than one value.


$('#property_search_results').load('search.php', {towns:['Apalachin','Owego','Binghamton']});

Web servers will first define the "town" variable with "Apalachin". It will then immediately overwrite "Apalachin" with "Owego", and then overwrite "Owego" with "Binghamton".

If we change the variable name to towns[] within the AJAX functions, web servers will know that this is an array of values and all will be well. This is same way that web browsers pass an array of values for one variable in forms and query strings.

Attachments (1)
  • param.diff (1.7 KB) - added by flesler May 14, 2008 10:12PM UTC.

    This is the change, but I think I won't be able to apply it as many people/servers don't expect this to happen.

Change History (2)

Changed May 11, 2008 10:11PM UTC by flesler comment:1

component: coreajax
owner: → flesler
priority: majorminor
status: newassigned
type: bugenhancement

Will look into it.

Changed May 14, 2008 10:29PM UTC by flesler comment:2

resolution: → wontfix
status: assignedclosed

According to this, the index/key shouldn't be specified.

So I'll have to close this, you can apply the diff to your file if you want, or you can just use:


That should work as expected.