Dmitry Dmitry - 4 months ago 5
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

encodeURI
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?

UPDATED:

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

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

"bla&bla&bla"

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

"bla%26bla%26bla"