title: onclick get data from database using ajax laravel
body: <p>What I am trying to do is to load <code>data-id</code> in drop-down menu when I click the list item, it need retrieve the data from db and append in table.   </p>
  
  <p>So far, I loaded the data id in drop-down menu and while on-click the list I send ajax call to retrieve data. </p>
  
  <p><strong>My code (controller page):</strong></p>
  
  <pre><code>public function calcList($id)
  {
  
      $designId=design::find($id);
      $design = design::select( `design_no`, `design_name`, `weight_length`, `quantity`, `design_image`, `des2`, `des3`, `des4`, `des5`, `des6`, `des7`)-&gt;where('id','=',$designId);
      // return Response::json(array('datas' =&gt; $design));
      // return response()-&gt;json(['data'=&gt;$design]);
      return Response::json($design);
  }  
  </code></pre>
  
  <p><strong>Ajax Request:</strong>  </p>
  
  <pre><code>$(document).ready(function() {
      $('.designList').click(function() {
          $.ajaxSetup({
              headers: {
                  'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
              }
          });
  
          var id =($(this).attr("data-id"));
          $.ajax({
               type:"POST",
               url:"/calc_list/"+id,
               success : function(results) {
                   console.log(results);
               }
          }); 
      });
  });  
  </code></pre>
  
  <blockquote>
    <p>On the console log, the results print like {..}<br>
    How to built the json to table?</p>
  </blockquote>