I have following script:
jQuery('#content-page-<?php echo $post->ID ?>')
.data('content','<div class="page-content"><?php echo $post->post_content; ?>');
In
'<div class="page-
The
'
symbol is not understood correctly and I get the
Uncaught SyntaxError: Unexpected token ILLEGAL
AND
unterminated string literal
error in chrome and firefox.
What is the problem?
UPDATE 1
The
<?php echo $post->post_content; ?>
How to handle multiline text? The problem seems to be in multiline.
Are there any apostrphes in the php output? If so remember it becomes “raw text” so if it echos “I’m bob” it’ll render as
'content',';I'm bob'(notice the middle quote). So you should use something likeaddslashes($post->$post_content)http://php.net/manual/en/function.addslashes.php to escape the output.