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!
{"success":true,"type":"add"}
Here is my Jquery function
```
<script>
$(function(){
display();
//add new
function display(){
$.ajax({
type:'ajax',
url:'<?php echo base_url()?>frame_cont/display',
async: false,
dataType:'json',
success:function(data){
var html='';
var i;
for(i=0;i<data.length;i++){
html +='<tr>'+
'<td>'+data[i].id+'</td>'+
'<td>'+data[i].username+'</td>'+
'<td>'+data[i].email+'</td>'+
'<td>'+data[i].password+'</td>'+
'<tr>';
}
$('#showdata').html(html);
},
error:function(){
alert('Could not get Data from Database');
}
});
};
});
</script>```
and here is controller class
<?php
class Frame_cont extends CI_Controller{
public function index(){
$this->load->view('index');
}
public function register(){
$this->load->model('frame');
$result=$this->frame->insert();
$msg['success']=false;
$msg['type']='add';
if($result){
$msg['success']=true;
}
echo json_encode($msg);
}
public function display(){
$this->load->model('frame');
$result=$this->frame->display();
echo json_encode($result);
}
}
This is all about the code and sorry for the english