Laravel foreach ajax get HTTP 500 - development

Laravel foreach ajax get HTTP 500

This is my ajax

    $('#absensi').on('show.bs.modal', function (event) {
    var button = $(event.relatedTarget);
    var data_kelas = button.data('pkelas');
    var id = button.data('pid');
    var modal = $(this);
    //console.log(id);
    document.getElementById("vkelas").innerHTML = data_kelas;
    $.ajax({
      type : 'get',
      url : '',
      data : {'id': id},
      success:function(data){
        console.log(data); //check 
        $('#siswa').html(data);
      }
    });
  });

This is My Controller

      $output="";
      $admin = Auth::user()->sekolah_id;
      $murids= Student::where('sekolah_id', $admin)
      ->where('ruang_id', $request->id)
      ->get();
      if ($murids)
      {
        $i=1;
        foreach ($murids as $murid)
        {
          $stu .= '<tr><td>'.$i++.'</td>
                  <td>'.$murid->name.'</td>
                  </tr>';
        }
        return Response($stu); //show on html
      }

and I got error like this:

GET http://127.0.0.1:8000/detailclass?id=1 500 (Internal Server Error)

Can you help me?



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-foreach-ajax-get-http-500/
via Lzo Media

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-include of inline SVG does not display gradient except in Chrome