mardi 18 décembre 2018

Iternal server error 500 ajax whats the problem

Hi So here is my code i am tryied to give laravel ajax value its very simple ajax code but i am getting internal error 500 and rly dont know why ...

this is my code for ajax . and inputs

<body>
  <div class="container">
    <div class="form" a >
      <form class="post_form">
        @csrf
        <input type="text" id ='text' name="text" value="">
        <input type ='submit'class= 'aeee'  val ='iobani'>
        <button type="button" class= 'aa'  name="button">aa</button>
      </form>

    </div>





  <script>

  $(document).ready(function(){

    $(".post_form").on('submit', function(e) {


    var post = $('.post_form').serialize();


      $.ajax({

        headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
           method: 'POST',
           url: '/add_com',
           data: post,
           dataType: "json",

           success:function(data){
             console.log('ess');
           },
           error:function(data){
             console.log('error');
           }

      });

      e.preventDefault();

    });




  });




  </script>

</body>

here is code in laravel public function store(Request $request) {

  $post = Post::create([
    'text' => $request->text,

  ]);




  $view = view("/",compact('post'))->render();

      return response()->json(['html'=>$view]);




}

i think i tried everything but still this 500 error could anyone tell me why ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire