mammouth
asked on
json_decode fron encodeURIComponent strignify error on %0A and %22 from textarea
im getting error on json_decode(url_decode($va r)) when a value of the array $var contain $0A or %22.
on JS side:
var obj = new Object;
obj.id = 1;
obj.txt = encodeURIComponent($('txt' ).value);
then i use YUI! Connect.asyncRequest to send data using strignify to php.
JSON.stringify(obj)
On php side i decode the string using:
$obj = json_decode(urldecode($_PO ST['obj']) );
The $_POST['obj'] contain "%0A" for skipped line and %22 for " and this return error when im getting the value.
How can i resolve this?
on JS side:
var obj = new Object;
obj.id = 1;
obj.txt = encodeURIComponent($('txt'
then i use YUI! Connect.asyncRequest to send data using strignify to php.
JSON.stringify(obj)
On php side i decode the string using:
$obj = json_decode(urldecode($_PO
The $_POST['obj'] contain "%0A" for skipped line and %22 for " and this return error when im getting the value.
How can i resolve this?
ASKER
Not it only seem to fail when someone add the & char into the textarea.
like "me & you"
like "me & you"
ASKER
sorry: no "Not" but "now"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello mammouth,
What's up? It don't work ?
Regards.
What's up? It don't work ?
Regards.
No feedback ? :(
ASKER
it work's if i encodeURIComponent obj and not only obj.txt
Try :
Open in new window