title: Pass data from controller to view using JQuery Ajax in Laravel 5.4
body: <p>I have a laravel app having a modal in which I wish to perform a search in the database and display info in the same modal without reloading the page (which would cause the modal to disappear).</p>
  
  <p>For that I am using jquery/ajax to pass data to the controller and get result.</p>
  
  <p>However I am not getting the correct format of data returned from the controller. Or maybe should I change something in the jQuery/AJAX.</p>
  
  <p>The result I am getting is: </p>
  
  <pre><code>{{ $temoin-&gt;nnid }} {{ $temoin-&gt;nom }}  {{ $temoin-&gt;postnom }}  {{ $temoin-&gt;datenaissance }}
  </code></pre>
  
  <p>Any advice?</p>
  
  <p>The code:</p>
  
  <p>route</p>
  
  <pre><code>Route::post('/nouveau_ne', ['uses' =&gt; 'AdulteController@rechercheAdulte']);
  </code></pre>
  
  <p>the jQuery/AJAX</p>
  
  <pre><code>$("#search_witness_btn").on('click', function() {
      var nnid_temoin = $('#nnid_temoin').val();
      if ($.trim(nnid_temoin) != '') {
          alert('ok '+nnid_temoin);
          $.post('/nouveau_ne',{nnid_temoin:nnid_temoin}, function(data) {
              $('#result_temoin').html(data);
          });
      } else {
          alert('ok '+nnid_temoin);
      }
  });
  </code></pre>
  
  <p>The Controller</p>
  
  <pre><code>$nnid_temoin = $request-&gt;input('nnid_temoin');
  
  $temoin = t_adulte::join('t_individus', 't_adultes.nnid', '=', 't_individus.nnid')
      -&gt;select(['t_individus.nnid','t_individus.nom','t_individus.postnom','t_adultes.datenaissance'])
      -&gt;where('t_adultes.nnid','=',$nnid_temoin)
      -&gt;get();
  
  $result = '&lt;td&gt;{{ $temoin-&gt;nnid }}&lt;/td&gt;&lt;td&gt;{{ $temoin-&gt;nom }}&lt;/td&gt;&lt;td&gt;{{ $temoin-&gt;postnom }}&lt;/td&gt;&lt;td&gt;{{ $temoin-&gt;datenaissance }}&lt;/td&gt;';
  return $result;
  </code></pre>