title: change/update page content without reloading page - by AJAX Laravel
body: <p>I have a simple view, which displays results of a query</p>
  
  <pre><code>$number = 5;
  $events = Event1::has('users', '&lt;', 1)-&gt;latest()-&gt;take($number)-&gt;get();
  </code></pre>
  
  <p><strong>TASK:</strong>
  Now I want to create some filter and sorting methods... and be able to refresh the displayed results without page reload</p>
  
  <p>In my view file I have this: </p>
  
  <pre><code>&lt;div id="top5-list"&gt;
  @foreach($events as $event)
   ///
  @endforeach
  
  &lt;/div&gt;
  </code></pre>
  
  <p>**</p>
  
  <h2>TO DO</h2>
  
  <p>**
  <strong>I wish to implement the below scenarios</strong>, if possible working in the same VIEW:</p>
  
  <p><strong>SCENARIO 1)</strong> using the same query, but change the value of parameters - just like in the example above - the variable $number changes the number of displayed results. </p>
  
  <p>Most preferably I'd wish to use more than one variable</p>
  
  <p><strong>SCENARIO 2)</strong> build a separate query for each user-selectable viewing mode - for example </p>
  
  <p><strong>filter named: show top</strong> - refreshes the content with this query: </p>
  
  <pre><code>$events = Event1::has('users', '&lt;', 1)-&gt;latest()-&gt;take($number)-&gt;get();
  </code></pre>
  
  <p>and <strong>filter named show best</strong> - refreshes the content with results of this completely rebuilt query:</p>
  
  <pre><code>$events = Event1::whereHas('users', function($q){
  $q-&gt;where('importance', 0);})-&gt;get();
  </code></pre>
  
  <p>Scenario 2-A</p>
  
  <p>In one view I will have a top-10 list of more than one item, for example 
  TOP 5 EVENTS and TOP 5 ENTITIES side by side</p>
  
  <p>My desired function: by pressing a button the queries responsible for displaying the top-5 would be changed from, for instance switching from "top-5-most important"</p>
  
  <pre><code>$events = ...query_1...
  $entities = ...query_1...
  </code></pre>
  
  <p>into "top-5-most popular"</p>
  
  <pre><code>$events = ...query_2...
  $entities = ...query_2...
  </code></pre>
  
  <p><strong>SCENARIO 3)</strong> My ltimate goal is to build a filter which might sort out Books on-the-fly by clicking none, one, or many genres. Just as my other question demonstrates: <a href="https://stackoverflow.com/questions/27665636/how-to-filter-records-filtered-by-more-than-one-criterion-in-pivot-table-larav">how to filter records filtered by more than one criterion in pivot table - laravel eloquent collections</a></p>