开发者

How to encode value with jquery serialize?

开发者 https://www.devze.com 2023-03-19 05:39 出处:网络
I tried to encode all values like encodeURIComponent($(\"#customer_details\").serialize()); and that doesn\'t work as expected.

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开发者_如何学Go form and use encodeURIComponent to encode each value?


It 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.net/WArUG/

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

0

精彩评论

暂无评论...
验证码 换一张
取 消