title: Json Data print after insert a record using Jquery Ajax in CodeIgniter
body: <p><strong>I am using Jquery Ajax in Codeigniter, after register a user via bootstrap modal I got JSON data as below instead of fetching the data from table. Where I am wrong? please help!</strong></p>
  
  <p>{"success":true,"type":"add"}</p>
  
  <p><strong>Here is my Jquery function</strong></p>
  
  <pre><code>```
  &lt;script&gt;
  $(function(){
      display();
      //add new
  
  function display(){
      $.ajax({
          type:'ajax',
          url:'&lt;?php echo base_url()?&gt;frame_cont/display',
  
          async: false,
          dataType:'json',
          success:function(data){
              var html='';
              var i;
              for(i=0;i&lt;data.length;i++){
  
                  html +='&lt;tr&gt;'+
                              '&lt;td&gt;'+data[i].id+'&lt;/td&gt;'+
                              '&lt;td&gt;'+data[i].username+'&lt;/td&gt;'+
                              '&lt;td&gt;'+data[i].email+'&lt;/td&gt;'+
                              '&lt;td&gt;'+data[i].password+'&lt;/td&gt;'+
                              '&lt;tr&gt;';
              }
              $('#showdata').html(html);
          },
          error:function(){
              alert('Could not get Data from Database');
          }
  });
  };
  });
  &lt;/script&gt;```
  </code></pre>
  
  <p><strong>and here is controller class</strong></p>
  
  <pre><code>&lt;?php 
  class Frame_cont extends CI_Controller{
      public function index(){
          $this-&gt;load-&gt;view('index');
      }
  
      public function register(){
          $this-&gt;load-&gt;model('frame');
          $result=$this-&gt;frame-&gt;insert();
          $msg['success']=false;
          $msg['type']='add';
          if($result){
              $msg['success']=true;
          }
          echo json_encode($msg);
          }
  
  
  
  
      public function display(){
          $this-&gt;load-&gt;model('frame');
          $result=$this-&gt;frame-&gt;display();
          echo json_encode($result);
      }
  }
  </code></pre>
  
  <p><strong>This is all about the code and sorry for the english</strong></p>