hi i'm newbie in codeigniter. xD I want to change content without refreshing all page. my js code :
<script type="text/javascript">
$(document).ready(function(){
$('#submit').click(function(e) {
e.preventDefault();
//get input data as a array
var post_data = {
'message': $("#message").val(),
'<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
};
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>ccoba/insertByajax",
data: post_data,
success: function(message) {
$('#input_kategori').modal('toggle');
//$('.first:first').after('<tr><td></td><td></td><td>'+message+'</td></tr>');
$('#tabel').load('<?php echo base_url(); ?>ccoba/index'+"#tabel");
//reset modal form
$('.modal').on('hidden.bs.modal', function(){
$(this).find('form')[0].reset();
});
}
});
});
});
</script>
and my question's Can i call div element in a view with my controller??
this is my controller :
.......
function tabel(){
$data['hasil'] = $this->mcoba->getAllMessage();
$this->load->view('tbl_coba',$data); //i want to call div element in a view here
}
........
sorry about my bad english xD thnks..
No way to do this. You can create a html file that contains only the div. File HTML may be:
<div id="tbl_coba"> Your thing </div>
And then you put the filename of your file in:
$this->load->view('filename', $data);
Or you can modify the framework that you're using to make it satisfying what you want. But It's very complicated. Hope that help.