I'm getting the string from controller:
var x = '<?php echo addcslashes($this->x, "'") ?>';
The parsed result is:
var x = '<script>alert(\'x\')</script>';
Error:
Uncaught SyntaxError: Invalid or unexpected token
I tried to assign the string directly from JS and it works.