最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to encode value with jquery serialize? - Stack Overflow

programmeradmin3浏览0评论

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?

Share Improve this question edited Jul 11, 2011 at 17:19 pimvdb 155k80 gold badges311 silver badges356 bronze badges asked Jul 11, 2011 at 17:17 Gihan LasitaGihan Lasita 3,05314 gold badges49 silver badges66 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 14

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

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

发布评论

评论列表(0)

  1. 暂无评论