Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#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:


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 ajpiano

Owner: set to cowboy
Status: newassigned

comment:2 Changed 12 years ago by cowboy

Resolution: worksforme
Status: assignedclosed

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 12 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 12 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 12 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/

Note: See TracTickets for help on using tickets.