I have controller called Time
<?php
class Time extends CI_Controller {
// just returns time
public function index() {
echo time();
}
}
?>
this controller outputs the current time and that is loaded by using following code in a view.
window.setInterval(function() {
$.get('time/index',
// when the Web server responds to the request
function(time) {
$('#mydiv').html(time+'<br/>');
}
)
}, 5000);
As it can be seen only html response can be used only but what if I want Time
controller to return array, object or even a variable etc how can I do that?