Side navigation
#8472 closed feature (worksforme)
Opened March 08, 2011 05:19PM UTC
Closed March 30, 2011 07:17PM UTC
Last modified March 31, 2011 07:34AM UTC
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
Attachments (0)
Change History (5)
Changed March 30, 2011 06:52PM UTC by comment:1
owner: | → cowboy |
---|---|
status: | new → assigned |
Changed March 30, 2011 07:17PM UTC by comment:2
resolution: | → worksforme |
---|---|
status: | assigned → closed |
See the "JUST DO THIS" section of this example for a way to do this that doesn't require any changes to jQuery.
Changed March 31, 2011 06:34AM UTC by comment:3
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...
Changed March 31, 2011 06:58AM UTC by comment:4
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 "+"
Changed March 31, 2011 07:34AM UTC by comment:5
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/