title: how to test ajax page
body: <p>I've create a codeigniter app that includes a page with some ajax. 
  I'm trying to prove to myself that the ajax page is in fact working.  That is, that only one section of my page is being updated, and the rest stays as is. </p>
  
  <p>Here's my code in the controller: 
  (index is the method that is called on initial page load.  index2() is called when the refresh button is clicked)</p>
  
  <pre><code>       public function index()
         {
             $this-&gt;load-&gt;model('locations_model');
             $data['clienthistory'] = $this-&gt;locations_model-&gt;get_locations();
             $data['main_content'] = 'dashboard';
             $this-&gt;load-&gt;view('includes/template', $data);
         }
  
  
         public function index2()
         {
            $this-&gt;load-&gt;model('locations_model');
            $data['clienthistory'] = $this-&gt;locations_model-&gt;get_locations();
            return json_encode($data['clienthistory']);                                                                     
         }
  </code></pre>
  
  <p>And here is my view: </p>
  
  <pre><code> &lt;h2&gt;timer test&lt;/h2&gt;
      &lt;?php echo now();?&gt;
  
  &lt;h2&gt;Latest Client Status&lt;/h2&gt;
              &lt;?php echo form_open('Dashboard/index');          
              echo form_submit('submit', 'Refresh Client Data', 'id="clientsubmit" class="btn-primary"');
              ?&gt;
        &lt;div class="row-fluid"&gt;
               &lt;div class="span12" id="ajaxcontainer"&gt;
                 &lt;table class="table table-bordered table-striped"&gt;
                  &lt;thead&gt;
                   &lt;tr&gt;
                     &lt;th&gt;IP&lt;/th&gt;                                                                                                          
                     &lt;th&gt;Name&lt;/th&gt;                                                                           
                     &lt;th&gt;Last Updated&lt;/th&gt;
                   &lt;/tr&gt;
                   &lt;/thead&gt;
                  &lt;tbody&gt;
                 &lt;?php foreach ($clienthistory as $histitem): ?&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;?php echo $histitem['network'] ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $histitem['name'] ?&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;?php echo $histitem['lastupdated'] ?&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                 &lt;?php endforeach ?&gt;
  
                  &lt;/tbody&gt;
                 &lt;/table&gt;
         &lt;/div&gt;
  
       &lt;?php echo form_close();  ?&gt;
       &lt;script type="text/javascript"&gt;
          $('#clientsubmit').click(function() {                   
                 $.ajax({                                
                      url:"&lt;?php echo site_url('Dashboard/index2'); ?&gt;",
                      type: 'POST',
                      dataType: 'html'
                      success: function(returnDataFromController) {
                            $('#ajaxcontainer').html(returnDataFromController)
                      }
                    });
  
         return false;      
       });
      &lt;/script&gt;
  </code></pre>
  
  <p>The idea is to display the current time on the page, in an area that is not supposed to be updated by my ajax call.  But when I click on my refresh button, in addition to updating the table data, the time is being updated too. 
  I'm not sure I understand why this is happening. any help would be appreciated.  apologize in advance for the remedial questions - just new to codeigniter and to ajax.
  thanks.</p>