title: search with ajax laravel
body: <p>I need my project to have a search form, I tried with this code, but when I execute console it says:</p>
  <blockquote>
  <p><code>POST http://localhost:8000/buscar 500 (Internal Server Error)</code></p>
  </blockquote>
  <p>then here is my view</p>
  <pre><code>&lt;div id=&quot;qnimate&quot; class=&quot;off&quot;&gt;
      &lt;div id=&quot;search&quot; class=&quot;open&quot;&gt;
          &lt;button data-widget=&quot;remove&quot; id=&quot;removeClass&quot; class=&quot;closeSearch&quot; type=&quot;button&quot;&gt;×&lt;/button&gt;
              &lt;input type=&quot;text&quot; placeholder=&quot;Buscar Noticias -  Articulos - Reviews&quot;  id=&quot;buscar&quot; onkeydown=&quot;keydownFunction()&quot; onkeyup=&quot;keyupFunction()&quot;&gt;
              &lt;button class=&quot;btn btn-lg btn-site&quot; type=&quot;submit&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-search&quot;&gt;&lt;/span&gt; Buscar&lt;/button&gt;
          &lt;div id=&quot;resultadoBusqueda&quot; class=&quot;col-md-12&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>here is my controller</p>
  <pre><code>public function buscar()
      {
          $keywords = Input::get('keywords');
          $reviews = Reviews::where('estado','1')-&gt;take();
          $buscarReviews = new \Illuminate\Database\Eloquent\Collection();
          foreach ($reviews as $review) {
              if(Str::contains(Str::lover($review-&gt;nombre), Str::lover($keywords)))
                  $buscarReviews-&gt;add($review);
          }
          return view::make('busqueda')-&gt;with('buscarReviews', $buscarReviews);
      }
  </code></pre>
  <p>here is the view which shows the information</p>
  <pre><code>@foreach($buscarReviews as $review)
      &lt;div id=&quot;reviews&quot; class=&quot;col-md-12&quot;&gt;
          &lt;a href=&quot;/review/{{$review-&gt;slug}}&quot; class=&quot;link&quot;&gt;&lt;/a&gt;
          &lt;div class=&quot;col-md-4&quot;&gt;
              &lt;img src=&quot;Imagenes/{{$review-&gt;logo}}&quot; width=&quot;50&quot;&gt;
          &lt;/div&gt;
          &lt;div class=&quot;col-md-8&quot;&gt;
              &lt;h2&gt;{{$review-&gt;nombre}}&lt;/h2&gt;
              &lt;div&gt;{!! str_limit($review-&gt;descripcion, $limit = 150, $end = '...') !!}&lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  @endforeach
  </code></pre>
  <p>here is my js</p>
  <pre><code>var timer;
    function keydownFunction(){
      timer = setTimeout(function(){
          var keywords = $('#buscar').val();
  
          if(keywords.length &gt; 0){
            $.post('/buscar', {keywords: keywords}, function(markup){
              $('#resultadoBusqueda').html(markup);
            });
          }
  
      }, 500);
    }
    function keyupFunction(){
      clearTimeout(timer);
    }
  </code></pre>
  <p>I don't know what is the reason that it doesn't print the information required.</p>