Skip to main content

Bug Tracker

Side navigation

#14843 closed bug (notabug)

Opened March 04, 2014 04:29AM UTC

Closed March 04, 2014 03:14PM UTC

function buildParams not serialize Date in correct format.

Reported by: amarante.thiago@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.1.0
Keywords: Cc:
Blocked by: Blocking:
Description

buildParams the method serializes the date type to Content-Type: application / x-www-form-urlencoded string like "Fri Aug 20 1985 00:00:00 GMT-0400 (Eastern Daylight Time)"

correct would be:

function buildParams(prefix, obj, traditional, add) {

var name;

if (jQuery.isArray(obj)) {

Serialize array item.

jQuery.each(obj, function (i, v) {

if (traditional || rbracket.test(prefix)) {

Treat each array item as a scalar.

add(prefix, v);

} else {

Item is non-scalar (array or object), encode its numeric index.

buildParams(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add);

}

});

} else if (!traditional && jQuery.type(obj) === "object") {

Serialize object item.

for (name in obj) {

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

}

} else if (jQuery.type(obj) == "date") {

add(prefix, obj.toISOString());

} else {

add(prefix, obj);

}

}

Attachments (0)
Change History (1)

Changed March 04, 2014 03:14PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

That is the browser's .toString() representation of a Date object. If you want something different, convert it to the desired string format before passing to the API.