I tried to encode all values like
encodeURIComponent($("#customer_details").serialize());
and that doesn't work as expected.
Is there way to get all elements on form and use encodeURIComponent
to encode each value?
I tried to encode all values like
encodeURIComponent($("#customer_details").serialize());
and that doesn't work as expected.
Is there way to get all elements on form and use encodeURIComponent
to encode each value?
1 Answer
Reset to default 14It should already be encoded when using the serialize()
[docs] method.
From the docs:
The
.serialize()
method creates a text string in standard URL-encoded notation.
Example: http://jsfiddle/WArUG/
If you want to represent a space with a %20
instead of a +
, you'll need to do a .replace(/\+/g,'%20')
.