JSON htmlentities javascript
Posted
by Wessel Rossing
on Stack Overflow
See other posts from Stack Overflow
or by Wessel Rossing
Published on 2010-03-17T13:25:09Z
Indexed on
2010/03/17
13:41 UTC
Read the original article
Hit count: 525
Hi!
I am using an XMLHttpRequest to POST a JSON string to PHP. The JSON object is created in JavaScript and using the JSON2.js from json.org to create an JSON string representing the object.
JSON.stringify(object);
Whenever the object contains a string which has a special character in it, e.g. é, JavaScript does not give any error but PHP receives an empty array
[]
Is there a JavaScript function which produces the exact same resutls as the PHP function
htmlentities()
The data is send via POST, so the following functions
escape()
encodeURI()
encodeURIComponent()
are a bit overkill.
Thanks!
© Stack Overflow or respective owner