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

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -