form submit through ajax

Posted in CategoryLaravel
  • R
    Rajinder 1 month ago

    I am try to insert form value into database using ajax but unable.I got message in success when insert query is commented.Otherwise it genrate 500 internal server error.

     

    Help!!!!!!!!!!

     

    public function commentpost(Request $request){

    $input = request()->all();

    $postid= $input['postid'];

    $comment= $input['comment'];

    DB::table('comments')->insert(['postid'=>$postid,'comment'=>$comment]);

    return response()->json(['success'=>'Ajax working fine']);

     

    }

  • S
    Shruti 2 weeks ago

    use create instead of insert and check.

     

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *