Dmitry Dmitry - 6 months ago 12
Javascript Question

How to prepare encoded POST data on javascript?

I need to send data by POST method.

For example, I have she string "bla&bla&bla". I tried use

and got "bla&bla&bla" as result. I need to replace "&" by something correct on this exaple.

What kind of method should I call to prepare correct POST data?


I need to convert only charachters which may broke POST request. Only them.

>>> encodeURI("bla&bla&bla")


>>> encodeURIComponent("bla&bla&bla")