I have problem about passing data from controller to js, i am using this code for it ,i tried many things but nothing is working , am i doing something wrong ?
script:
var posts = {!! $post->toJson() !!};
alert(posts);
and my controller looks like this :
$post = Post::where('category',$id)->get();
but i am getting error "Uncaught SyntaxError: Unexpected token !" i really dont know why is there any solutions ?