Laravel code :
$teachers = Teachers::where('possessed_by_community', $communityId)->pluck('teacher_name');
return view('pages.show_add_teachers', [
'teachers' => $teachers
]);
Then in client side I tried :
var teachers = "<?php echo json_encode($teachers) ?>" ;
teachers = JSON.parse(teachers);
console.log(teachers);
In webconsole I get :
SyntaxError: missing ; before statement
In firefox debugger :