Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#10292 closed bug (duplicate)

ajax data cannot send empty array

Reported by: tenev@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.3
Keywords: Cc:
Blocked by: Blocking:

Description

An empty array or an empty object cannot be send via jQuery.ajax()

to reproduce:

$.ajax({
   url: 'test.php',
   type: 'post',
   data: {empty:[]},
});

In this case the "empty" array is not sent to the server.

Change History (6)

comment:1 Changed 8 years ago by anonymous

jsFiddle example of the bug http://jsfiddle.net/cjubX/

comment:2 Changed 8 years ago by dmethvin

Resolution: duplicate
Status: newclosed

comment:3 Changed 8 years ago by dmethvin

Duplicate of #6481.

comment:4 Changed 7 years ago by anonymous

I can reproduce this bug again in 1.9.1.

In Javascript console, I do:

$.get("/items/do_work", {abc: []})

On server end (Rails), I get:

Started GET "/items/do_work?def=&ghi%5B%5D=3" for 127.0.0.1 at 2013-02-10 10:46:10 -0800
Processing by ItinerariesController#start_info_update as */*
  Parameters: {"def"=>"", "ghi"=>["3"]}

comment:5 Changed 7 years ago by dmethvin

Please do not attach unrelated bug reports to closed bugs.

comment:6 Changed 7 years ago by m@…

Their bug report was not unrelated and I am running into the same problem. jQuery 1.9.1 is not able to send "empty" objects like the following one via an ajax-request.

{abc: {}}
Note: See TracTickets for help on using tickets.