title: Manual autocomplete search with Laravel, how to pass on info to div's in views
body: <p>Im trying to make a autocomplete search, that searches from a string in a input, in my database from several tables, like Persons, Users, and Bands. Using Laravel 4.2.</p>
  
  <p>I then want three objects to be accessed, and updated, in a #div on the view im already at.</p>
  
  <p>I have tried alot, but this one was hard. My solution worked on localhost but not online, but it was a bad solution anyway, by passing a view with->(the objects). Failed online since headers already are sent.</p>
  
  <p>I think my solution should be something like this:</p>
  
  <p>View:</p>
  
  <pre><code>{{ Form::open(['action' =&gt; ['SearchController@search'], 'method' =&gt; 'post']) }}
  {{ Form::text('term', '', ['class' =&gt; 'uk-width-1-1', 'id' =&gt;  'term', 'placeholder' =&gt;  'Søk etter person'])}}
  {{ Form::close() }}
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>   public function search(){
      $term = Input::get('term');
  
      $fest = Session::get('festival');
      $festival = Festival::find($fest);
  
          $persons = DB::table('fs_persons')
              -&gt;join('fs_festival_persons', 'person_id','=','fs_persons.id')
              -&gt;where('festival_id', '=', $fest)
              -&gt;get();  
  
      foreach ($persons as $query)
      {
          if ((strpos(strtolower($query-&gt;firstname), strtolower($term)) !== false) OR ((strpos(strtolower($query-&gt;lastname), strtolower($term)) !== false))) {
             $results[] = [ 'id' =&gt; $query-&gt;id, 'value' =&gt; $query-&gt;firstname.' '.$query-&gt;lastname, 'tlf' =&gt; $query-&gt;tlf ];
          }
  
  }
  return Response::json($results);
  }
  </code></pre>
  
  <p>But im unsure how to use it properly, here is just one object, tried making a multilevel array with objects, but it is all very confusing for me. This is alittle bit code from the jquery autocomplete, i get that working but I want my own presentation of the search results. </p>
  
  <p>I would love to be able to do, in a view, that gets updated on keyup on the search input, and where i can use blade templating:</p>
  
  <pre><code>@if($persons)
   @if(sizeof($persons)&gt;0)
      &lt;div class="uk-width-small-4-4"&gt;
      Personar:
      &lt;/div&gt;
      &lt;div class="uk-width-small-4-4"&gt;
      @foreach($persons as $person)
      &lt;?php
                  $tmp_pers = Person::find($person-&gt;id);
  ?&gt;
  
      &lt;span class="search_name"&gt;
      &lt;a href='{{ URL::to("festival/$festivalen-&gt;slug/person/$person-&gt;id") }}'&gt;
      {{ $person-&gt;firstname }} {{ $person-&gt;lastname }}
      &lt;/a&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  @endforeach
  @endif
  @endif
  </code></pre>
  
  <p>But im unsure on how to make\retrieve variables out of json, all this was much harder than I expected, so hoping anyone could guide me, thanks!</p>