I am having “SyntaxError: Unexpected token ILLEGAL” error on chrome.
<?
$data = "this is description
new line";
?>
$(".gantt").gantt({
desc: "<? echo $data; ?>"
});
the error is between “this is description” and “new line”. Why I cant use enter there? Is there a way to awoid this?
You can’t have (unescaped) new lines in JavaScript strings.
You are outputting:
The new line after
descriptionisn’t valid.You need to
json_encodeyour value (yes,json_encodeworks on plain strings too).Note that I removed the quotes.
json_encodewill add quotes for you.