Modify ↓
Ticket #10090 (closed bug: invalid)
ajax is sending null on Date type data
| Reported by: | martin.borthiry@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.6.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Jquery.ajax is sending null/undefined when the data type is Date() .
Browser Chrome 10+/FFX 5, OS Win/Linux/Mac.
Ej: $.post('send.php',{val:new Date()});
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

jQuery $.ajax supports serializing plain Objects and primitive types to string. It doesn't know how to serialize a Date object to a string in a universal way. Did you want the .getTime() value sent, or the ISO-8601 date format as a string (with or without the time)? By default, JavaScript usually converts a Date object to a *locale-defined* string, which is almost certainly NOT good.
Convert the value to string representing the value you want to send before you give it to $.ajax.