Ticket #8472 (closed feature: worksforme)
Transform object to flat array
| Reported by: | raziel057 | Owned by: | cowboy |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.5.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
It could be interesting to have a method to serialize deep objects to flat array in order to submit data from a form (NOT IN AJAX) to create a PDF for example.
See the sample: http://jsfiddle.net/dffQr/3/
I just added a possibility to specify a function in the Jquery.param() function
Change History
comment:2 Changed 2 years ago by cowboy
- Status changed from assigned to closed
- Resolution set to worksforme
See the "JUST DO THIS" section of this example for a way to do this that doesn't require any changes to jQuery.
comment:3 Changed 2 years ago by raziel057
Thanks, it's true, it can be done in a post traitment. And do you think it could be interesting to create a function paramsToFlatArray() for example with the content of your code? I don't know if it can be usefull for a general usage...
comment:4 Changed 2 years ago by anonymous
In fact there remain a problem with your code when the value contains some spaces as you can see here: http://jsfiddle.net/dffQr/7/
As result spaces are transformed in "+"
comment:5 Changed 2 years ago by anonymous
I can notice the following line in Jquery param() method:
Return the resulting serialization return s.join( "&" ).replace( r20, "+" );
Why the spaces are replaced by "+" ?
For now I just modify your code to replace "+" character to %20 before decoding as you can see here: http://jsfiddle.net/dffQr/11/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
