How to encode value with jquery serialize?

前端 未结 1 1194
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 11:39

I tried to encode all values like

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

and that doesn\'t work as expected.

Is

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 12:12

    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 讨论(0)
提交回复
热议问题