title: CodeIgniter - Refresh div after submit form
body: <p>My controller get datas from database model, and sends them to view. In view i do foreach loop to draw divs to each entity. Every single div has a form element to rate its entity.</p>
  
  <p>Controller:</p>
  
  <pre class="lang-php prettyprint-override"><code>function index(){
      $data['main_content'] = 'list';
      $data['entities'] = $this-&gt;database_model-&gt;getEntities();
      $this-&gt;load-&gt;view('template', $data);
  }
  
  function postRate(){
      $rate = array(
          'entity_id' =&gt; $this-&gt;input-&gt;post('entity_id'),
          'owner_id' =&gt; $this-&gt;input-&gt;post('owner_id'),
          'value' =&gt; $this-&gt;input-&gt;post('value')
      );
      $this-&gt;database_model-&gt;persistRate($rate);
      $this-&gt;index();
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre class="lang-php prettyprint-override"><code>function getEntities(){
      return $this-&gt;db-&gt;get('entity')-&gt;result();
  }
  
  function persistRate($rate){
      return $this-&gt;db-&gt;insert('rate', $rate);
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php foreach($entities as $entity) : ?&gt;
      &lt;div class="entity"&gt;
          &lt;?php echo form_open('entities/postRate/', $attr); ?&gt;
          &lt;?php echo form_hidden('entity_id', $entity-&gt;id); ?&gt;
          &lt;?php echo form_hidden('owner_id', $userid); ?&gt;
          &lt;?php echo form_hidden('value', 1); ?&gt;
          &lt;?php echo form_submit('submit', '+1'); ?&gt;
          &lt;?php echo form_close(); ?&gt;
      &lt;/div&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>In this case after rating, entire page will be reloaded but i want to refresh only that div where form was submited. I know javascript or jQuery can do it, ..
  UPDATE
  .. but i don't know their logics, how will they know the exact div or the exact (updated) data of actual entity ? Shall i get it from database? i'm just confused with js/jquery/ajax.</p>