title: Laravel post + ajax
body: <p>I'm having a issue with laravel, i have a SPA running and i need to do a form with search and filters by category.</p>
  
  <p>I'm doing this via POST, but i need to run the query again with the filters, with ajax so the page don't reload.</p>
  
  <p>But how can i do that? I need to run just that query and reload the div, the ajax part is okay, but i don't know how to run just that query without running every query to "populate" the content from the page.</p>
  
  <p>Sorry if wasn't clear enough, my english is not to good.</p>
  
  <p>Thanks in advice!</p>
  
  <p>Controller:</p>
  
  <pre><code>public function index()
  {
      $data['servicos']                   = DB::select('SELECT * FROM servicos WHERE ativo = 1 ORDER BY ORDEM ASC');
      $data['servicos_processo']          = DB::select('SELECT * FROM servicos_processo WHERE ativo = 1 ORDER BY ID ASC');
      $data['servicos_fun']               = DB::select('SELECT * FROM servicos_fun WHERE ativo = 1 ORDER BY ID ASC');
      $data['curriculum_historico']       = DB::select('SELECT * FROM curriculum_historico WHERE ativo = 1 ORDER BY ID DESC');
      $data['curriculum_educacao']        = DB::select('SELECT * FROM curriculum_educacao WHERE ativo = 1 ORDER BY ANO ASC');
      $data['curriculum_coding_skills']   = DB::select('SELECT * FROM curriculum_coding_skills WHERE ativo = 1 ORDER BY ID ASC');
      $data['curriculum_other_skills']    = DB::select('SELECT * FROM curriculum_other_skills WHERE ativo = 1 ORDER BY ID ASC');
      $data['curriculum_testimonials']    = DB::select('SELECT * FROM curriculum_testimonials WHERE ativo = 1 ORDER BY ID ASC');
      $data['certificados_last']          = DB::select('SELECT * FROM certificados WHERE ativo = 1 ORDER BY data_conclusao DESC LIMIT 9');
      return view('main', $data);
  }
  
  public function certificados()
  {
      $nome = Request::input('filtro-certificados');
      $data['certificados_last']          = DB::select("SELECT * FROM certificados WHERE ativo = 1 AND nome LIKE '%{$nome}%' ORDER BY data_conclusao DESC LIMIT 9");
      return $data;
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code> &lt;div class="latest-posts media-grid masonry" data-layout="masonry" data-item-width="340"&gt;
  
                  @foreach($certificados_last as $certificado)
                  &lt;article class="hentry media-cell"&gt;
                      &lt;div class="media-box"&gt;
                          &lt;img src="images/certificados/{{$certificado-&gt;id}}.svg" style="padding:60px" alt="post-image"&gt;
                          &lt;div class="mask"&gt;&lt;/div&gt;
                          &lt;a href="certificado/{{$certificado-&gt;id}}"&gt;&lt;/a&gt;
                      &lt;/div&gt;
  
                      &lt;header class="media-cell-desc"&gt;
                              &lt;span title="2013" class="date"&gt;
                                  &lt;span class="day"&gt;{{$certificado-&gt;dia_conclusao}}&lt;/span&gt;{{$certificado-&gt;mes_conclusao}}&lt;/span&gt;
                          &lt;h3&gt;
                              &lt;a href="certificado/{{$certificado-&gt;id}}"&gt;{{$certificado-&gt;nome}}&lt;/a&gt;
                          &lt;/h3&gt;
                      &lt;/header&gt;
  
                  &lt;/article&gt;
                  @endforeach
  
              &lt;/div&gt;
  </code></pre>