Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#7568 closed bug (fixed)

jQuery 1.4.4 breaks data for ajax post if 'data' object contains a SUB OBJECT with key named "length"

Reported by: Arnoman Owned by: jitter
Priority: low Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by snover)

This kind of problem has already been reported in ticket 5862 and the problem has been fixed for the 'data' object but the problem remains for sub objects contained in 'data' object:

If there is a key named "length" in an sub object contained in the 'data' object, then the data are broken as the value of "length" is used to redefine the "array" length..

	    type: 'POST',
	    url: url,
	    data: {'test': {'length': 3, 'foo': 'bar'} },
	    success: ...

Data posted are:

test[0]	undefined
test[1]	undefined
test[2]	undefined

Change History (7)

comment:1 Changed 6 years ago by Arnoman

That's because of $.each() that think: "ok, you have a length property, then you are an array".

I would like to tell it: "well, no, it's not an array, it's an object that describe something long enough to have a length property"...

But it would for sure respond: "So it's an array-like". Luckily jquery functions do not speak.

comment:2 Changed 6 years ago by snover

  • Component changed from unfiled to ajax
  • Priority changed from undecided to low
  • Status changed from new to open

culprit. Should change that to use a for loop instead of $.each.

comment:3 Changed 6 years ago by snover

  • Description modified (diff)

comment:4 Changed 6 years ago by rwaldron

  • Keywords ajaxrewrite added

comment:5 Changed 6 years ago by jitter

  • Keywords ajaxrewrite removed
  • Milestone changed from 1.5 to 1.5.1
  • Owner set to jitter
  • Status changed from open to assigned

comment:6 Changed 6 years ago by Anton M

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

Fixes #7568. Follow-up fix for #5862. Objects with a length property weren't serialized properly by jQuery.param.

Changeset: 389c099df686bd104ce0aab3361a94ebf3a05ce6

comment:7 Changed 6 years ago by jitter

  • Version changed from 1.4.4 to 1.5
Note: See TracTickets for help on using tickets.