JSON htmlentities javascript
- by Wessel Rossing
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!