title: Codeigniter HMVC and calling a view from jQuery
body: <p>New to HMVC in Codeigniter.  </p>
  
  <p>Dynamic form allows new "segments" to be created when a user clicks a link.  </p>
  
  <p>Currently the segment html &amp; php is in module/view/segment_view.php.  The view requires dynamic php variables as well.  </p>
  
  <p>How can I "load the view" using jQuery? I understand I can't directly load a view from jQuery but am lost on how to structure the controller for an AJAX call.  Seems this may not be a strength of Codeigniter?  </p>
  
  <p><strong>EDIT:</strong><br>
  The "segment" is inside a form.  The form always has 1 segment.  jQuery can add more segments.  Each segment requires php arrays for form inputs and validation.  </p>
  
  <p>Here is a pared down version of the form_view file  </p>
  
  <pre><code>for ($i=1; $i&lt;=$number_of_segments; $i++) {
  
      $data['location'] = array(
          'name'  =&gt;  "segment[$i][location]",
          'value' =&gt;  set_value("segment[$i][location]"),
          'maxlength' =&gt;  '255',
          'size'  =&gt;  '30'
      );  
   ?&gt;
      &lt;div class="area"&gt;
          &lt;div class="row"&gt;&lt;h2&gt;Segment &lt;?php echo $i;?&gt;&lt;/h2&gt;&lt;/div&gt;
  
          &lt;?php 
          $this-&gt;load-&gt;view('module/segment_view', $data);
          ?&gt;
  
      &lt;/div&gt; &lt;!--/div class="area"--&gt;
  &lt;?php
  }    //end for
  ?&gt;
  </code></pre>
  
  <p>OK, so this isn't really separating application logic from presentation, now is it?  Ha ha.  So what is the best way to structure this so the code is HMVC and can be accessed from a php controller/view as well as jQuery?</p>