コントローラーを呼び出しましたTime
<?php
class Time extends CI_Controller {
// just returns time
public function index() {
echo time();
}
}
?>
このコントローラーは現在の時刻を出力し、ビューで次のコードを使用してロードされます。
window.setInterval(function() {
$.get('time/index',
// when the Web server responds to the request
function(time) {
$('#mydiv').html(time+'<br/>');
}
)
}, 5000);
ご覧のとおり、html 応答のみを使用できますが、Time
コントローラーに配列、オブジェクト、または変数などを返すようにするにはどうすればよいですか?