title: Loading files via AJAX with CodeIgniter/MVC
body: <p>I'm currently in the process of rewriting an entire <a href="https://www.sportannica.com/teams/ncaab/Army%20Black%20Knights" rel="nofollow noreferrer">site</a> of mine so that it's compatible with CI. I'm fairly new with CI and the MVC pattern in general. I followed this <a href="http://net.tutsplus.com/tutorials/php/an-introduction-to-views-templating-in-codeigniter/" rel="nofollow noreferrer">tutorial</a> and have made a pretty decent template for the view part of the MVC pattern. The thing is, a lot of my site uses jQuery/AJAX to make it more dynamic. For example, on all of my pages on my site, I have an input field that uses jQuery to load a PHP file upon keyup.</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
      $(&quot;#search_bar&quot;).keyup(function(){
          var search = $(&quot;#search_bar&quot;).val();
          var url = &quot;search_bar.php&quot;;
          var data = &quot;q=&quot;+ search;
  
          $('#livesearch').load(url, data);
          $(&quot;#livesearch&quot;).slideDown(&quot;fast&quot;);
      });
  &lt;/script&gt;
  
  &lt;input type='text' maxlength='30' id='search_bar' autocomplete='off' placeholder='Browse Teams' /&gt;
  &lt;div id='livesearch' style='display:none;'&gt;&lt;/div&gt;
  </code></pre>
  <p>All of the backend work that's required to load the results happens in the PHP file that loaded via jQuery (search_bar.php). So, should &quot;search_bar&quot; be its own View that's triggered by its own Controller and then Modeled by a model called &quot;search_bar&quot;? Again, I'm very new to the MVC pattern and am not quite sure how properly integrate AJAX with a object oriented framework like CI.</p>
  <p>Thanks</p>