#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: | ||
Blocked by: | Blocking: |
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 (5)
comment:1 Changed 12 years ago by
Owner: | set to cowboy |
---|---|
Status: | new → assigned |
comment:2 Changed 12 years ago by
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
comment:3 Changed 12 years ago by
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 12 years ago by
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 12 years ago by
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/
See the "JUST DO THIS" section of this example for a way to do this that doesn't require any changes to jQuery.