ilyatom ilyatom - 2 months ago 11x
Ajax Question

JSON.stringify replace pluses with spaces

I use AJAX and send string someString to php-handler"POST", url, true);
var someString = 'Foo+Bar';
var params = 'operation='+operation+'&json='+JSON.stringify(someString);

If someString contains '+' it replacing with space. As I could read, it is normal work of JSON.stringify, but how can I get pluses (using JS only)?

The second question is what other symbols replacing by JSON.stringify?


That has nothing to do with JSON.stringify.

The conversion of + to a is done by the URL parser on the server. A + is one of the ways you can represent a space in a URL (the other being %20).

To convert text to make it safe to insert into a URL, use encodeURIComponent.