I'm making a simple post page with Laravel. My posts tables has the following fields: title, slug, body. I want to pass the post info to a javascript variable:
post.blade.php:
<script>
var myPost=JSON.parse('{!! json_encode($post)!!}');
</script>
When the post body has characters as ({ or anyhting else it causes the following error: Uncaught SyntaxError: missing ) after argument list
This is a console.log: part of console.log(JSON.parse('{!! json_encode($post)!!}')})
how can I avoid that?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qLGX2D
via IFTTT
Aucun commentaire:
Enregistrer un commentaire