How to prepare encoded POST data on javascript?

前端 未结 5 1092
长发绾君心
长发绾君心 2021-01-04 04:10

I need to send data by POST method.

For example, I have the string \"bla&bla&bla\". I tried using encodeURI and got \"bla&bla&bla\" as t

5条回答
  •  礼貌的吻别
    2021-01-04 04:41

    Use encodeURIComponent() as encodeURI() will not encode: ~!@#$&*()=:/,;?+'

    This has been explained quite well at the following link:

    http://xkr.us/articles/javascript/encode-compare/

提交回复
热议问题