what I am trying to do here is after the insertion I want to display the data in the same page without refreshing the page
ROUTES
Route::post('viewBook/{bookId}', 'CommentsController@insertcomment');
//there's {bookId} cause of this http://localhost:8000/viewBook/1
CONTROLLER
public function insertcomment(Request $request)
{
$commenter = Auth::user()->id;
$comments = new Comments;
$comments->comment = $request->input('mycomment');
$comments->commenter = $commenter;
$comments->save(); //insert success
//getting the data
$data=DB::table('comments')
->select('comment')
->get();
return response()->json($data,true);
}
via donnah