How to put html in a javascript object?

0

What I'm doing is that in wordpress I'm creating an object with

post.push([

{
contenido: "<?php the_content(); ?>",
}
])

But when I do that, the content returns it to me in HTML and javascript marks it as an error.

    
asked by Angel 22.07.2018 в 23:35
source

1 answer

1

It seems that push should support a json. Therefore you should escape it.

You could try:

post.push([
{
contenido: "<?php json_encode(the_content()); ?>",
}
])
    
answered by 22.07.2018 в 23:47