4

I have a text in $faq['content']; and when i echo $faq['content'] this error is displayed in browser console:

' ' string literal contains an unescaped line break Error

My code:

<script>
setTimeout(function () {
$(".opencxbody").html('<div style="max-height:400px; overflow-y: scroll;"> <?php echo $faq['content']; ?></div>');
}, 100);
</script>
Farid
  • 158
  • 1
  • 2
  • 13
  • 2
    Seems like `echo $faq['content']` has newlines. So you're producing invalid JavaScript code, as you cannot have multiline string literals. – VLAZ Jun 09 '20 at 12:13
  • @VLAZ Yes thats true. $faq['content'] has newlines. have can i solve this problem? – Farid Jun 09 '20 at 12:16
  • 2
    Does this answer your question? [passing php string with multiple lines to a javascript function/variable](https://stackoverflow.com/questions/16660072/passing-php-string-with-multiple-lines-to-a-javascript-function-variable) – James Jun 09 '20 at 12:24

1 Answers1

0

Please try again.

<script>
setTimeout(() => {
            let data = "<div style='max-height:400px; overflow-y: scroll;'>";
                data += "<?=$sss?>";
                data += "</div>";
            $(".opencxbody").html(data);
        }, 100);
</script>
emresudo
  • 71
  • 3