I am able to display the text straight from database on a page. The thing is that when the text is edited in database, I want it to instantly reload and display the new text without reloading the page.
I am not able to make that happen and I don't know why it's not wokring. I want it to reload every 2 seconds.
My view file
<div id="results"></div>
<script>
$.ajax({
url: "<?php echo base_url('home/get') ?>",
cache: false,
success: function (html) {
$("#results").text(html);
},
Timeout:2000
});
</script>
My controller
public function get() {
$this->load->model('editor_model');
$result = $this->editor_model->get();
if ($result) {
echo $result->body;
}
}
It displays it but doesn't reload. Please help. Thanks!
alert(html)in success, check if its getting expected result...