Bug Tracker

Modify

Ticket #8472 (closed feature: worksforme)

Opened 2 years ago

Last modified 2 years ago

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:1 Changed 2 years ago by ajpiano

  • Owner set to cowboy
  • Status changed from new to assigned

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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.