Opened 9 years ago
Closed 9 years ago
#14843 closed bug (notabug)
function buildParams not serialize Date in correct format.
Reported by: | 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);
}
}
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.