0

i've used codeigniter relative_time helper created by yoeran. in ajax post i call function in controller to return relative time and admin name. but relative time alwayas return null. is helper not calling in ajax post ?

here my ajax code :

$.ajax({
        type: "POST"
        , url: baseurl +"admin/get_last_change/document"
        , dataType: "json"
        , data: {
            id: $(".page-heading small").attr('data-document-id')
        }
        , success: function (result) {
            $('#last-change').html(result.data);
            console.log(result.data);
        }
    });

and here my function in controller :

function get_last_change($keyword){
        $id = $_POST['id'];
        $where = array('target_id' => $id);
        if($keyword == 'document'){
            $result = $this->Admin_Model->get_task_admin(12, $where);
            $admin_name = $result->row('admin_account_name');
            $last_change = relative_time($result->row('created_at'));
            $data = "Last Change : ".$last_change." by <span class='text-primary'>".$admin_name."</span>";   
            $output = array('data' => $data);
        }
        echo json_encode($output);
    }

result of $result :

{"id":"12","created_at":"2016-05-17 09:52:14","admin_account_name":"Ibnu Habibie","task_name":"Add Content"}
Ibnu Habibie
  • 721
  • 1
  • 9
  • 20

0 Answers0