php javascript json parse escape characters -
I currently have a webpage which requires the use of javascript to parse the variable from php.
I work like this:
data.notices = JSON.parse ('& lt ;? php echo json_encode ($ notice)? & Gt;') ; However, when there are single or double quotes in the $ notice variable, javascript console return errors.
How can I get the variable properly?
This code does not return the error
gt; asdasd' 'adi ad') ;? & Gt; & Lt; Script & gt; Data = new object (); Data.notices = JSON.parse ('& lt ;? php echo addlashes (json_encode ($ notice))? & Gt;;;; & lt; / script & gt;
Comments
Post a Comment