How to encode a value using jquery serialize?

I tried to encode all the values, e.g.

encodeURIComponent($("#customer_details").serialize());

and it does not work properly.

Is there a way to get all the elements in a form and use encodeURIComponenteach value to encode?

+5
source share
1 answer

It should already be encoded using the serialize() [docs] method .

From the docs:

The method .serialize()creates a text string in standard encoding with URL encoding.

Example: http://jsfiddle.net/WArUG/

If you want to represent space with %20instead +, you need to do it .replace(/\+/g,'%20').

+14

All Articles