jQuery.param() - doesn't serialize javascript Date objects?
Posted
by ehahn9
on Stack Overflow
See other posts from Stack Overflow
or by ehahn9
Published on 2010-05-08T15:34:37Z
Indexed on
2010/05/08
15:38 UTC
Read the original article
Hit count: 262
jQuery.param({foo: 1}); // => "foo=1" - SUCCESS!
jQuery.param({bar: new Date()}); // => "" - OUCH!
There is no problem with encodeURIComponent(new Date()), which is what I would have thought param is calling for each member.
Also, explicitly using "traditional" param (e.g. jQuery.param(xxx, true)) DOES serialize the date, but alas, that isn't of much help since my data structure isn't flat.
Is this because typeof(Date) == "object" and param tries to descend into it to find scalar values?
How might one realistically serialize an object that happens to have Date's in it for $.post() etc.?
© Stack Overflow or respective owner