title: Implementing Filtering content using jquery ajax and php
body: <p>I had implemented multiple checkbox filtering for a job portal using <em>jQuery</em> where in I was calling a function every time a checkbox is checked and that function contained an ajax call which would send the request with the checked values and I would do the querying of database and return the result.</p>
  
  <p>But one of the developers I meet told me you should not hit the database continuously for filtering, it should be done client-side.<br>
  He also suggested to use <em><b>AngularJS</b></em> or <em><b>Knockout(js)</b></em> for the purpose, as they work on content, whereas <em>jQuery</em> works on DOM elements.</p>
  
  <p>But if it has to be done client-side, all of the data must be loaded at once during the first visit to the page, which in turn would slow down the page.<br>
  And I cannot use class on each element and show/hide them based on the checkbox ID or value something like that, because there are a lot of checkboxes, which I think will be hectic to handle.</p>
  
  <p><strong>How to achieve the desirable result with good performance?</strong><br>
  I'm a Newbie to <em>jQuery</em>, so if I have gone wrong anywhere bear with me.</p>
  
  <p>Below is the sample way in which I have actually done:</p>
  
  <hr>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;input type="checkbox" name="location[]" value="Bangalore" onclick="loadresult()"&gt;Bangalore
  </code></pre>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>function loadresult() {
      location array value accessed and passed to ajaxcall
      //ajax call to processresult.php
      Displaying the DB returned Data
  }
  </code></pre>
  
  <p><strong>PHP <i>(processresult.php)</i>:</strong></p>
  
  <pre><code>&lt;?php
      //dbconnection + querying db and returning result
  ?&gt;
  </code></pre>