Bug Tracker

Opened 11 years ago

Closed 11 years ago

#11481 closed bug (invalid)

jQuery.param does not serialize Date objects correctly

Reported by: JayAchTee Owned by: JayAchTee
Priority: low Milestone: None
Component: misc Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

When using deep serialization, JavaScript Date objects are not serialized correctly. They are skipped in the buildParams method "for (var name in obj)" code because they are typeof "object" but have no "name" property.

This bug was exposed by using Telerik's Kendo UI grid with server-side filtering enabled.

I tested using the following (near line 9048 of the unminified version) and it seems to resolve the issue:

if (obj instanceof Date) {

add(prefix, obj);

} else {

for (var name in obj) {

buildParams(prefix + "+ name +?", obj[name], traditional, add);

}

}

Change History (3)

comment:1 Changed 11 years ago by sindresorhus

Owner: set to JayAchTee
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 11 years ago by JayAchTee

Status: pendingnew

It appears that jQuery v1.7.2pre Live from Git has this fixed! Changing to "jQuery.type( obj ) === "object"" works as expected!

Thanks for your help on this issue!

Last edited 11 years ago by JayAchTee (previous) (diff)

comment:3 Changed 11 years ago by sindresorhus

Component: unfiledmisc
Priority: undecidedlow
Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.