モデルからコントローラーに、コントローラーから JSON 経由でビューにデータを渡そうとしています。
私のモデル:
public function GetRecordDetails($array){
    $this->db->select('*');
    $this->db->where('type', $array['event_type']);
    $this->db->where('id', $array['event_id']);
    return $this->db->get('records')->result_array();
}
私のコントローラー:
public function show_record(){
    $this->load->model('records_model');
    $data = array(
        "event_id" => $_POST['id'],
        "event_type" => $_POST['type']
    );
    $msg = array();
    if(empty($data['event_id']))                            $msg['failed'] = "failed"; else
    if(empty($data['event_type']))                          $msg['failed'] = "failed"; else
    if($this->records_model->CheckForRecord($data) == 0)    $msg['failed'] = "failed"; else
    if(count($msg) == 0){
        $array['data'] = $this->records_model->GetRecordDetails($data);
        $msg = array(
            "success" => "success",
            "id" => $data['event_id'],
            "country" => $array['data']
        );
    }
    echo json_encode($msg);
}
そして私の見解:
EVENT.show = function (id, type) {
$("#loader_" + id).html("<img src='images/loaders/loader2.gif' width='11px' height='11px' alt='loading' />");    
$("#failure").css('display', 'none');
$("#record_show").css('display', 'none');
var form_data = {
    id      : id,
    type    : type
}
$.ajax({
    url: "records/show_record",
    type: 'POST',
    dataType: 'json',
    data: form_data,
    success: function (data) {
        if(data.failed){
            $("#loader_" + id).html("");
            $("#failure").fadeIn(500);
            $("#msg_area").html(data.failed);
        }
        if(data.success){
            $("#loader_" + id).html("");
            $("#record_show").fadeIn(500);
                $("#record_id").val(data.id);
                $("#record_country").val(data.country);
        }
    },
    error: function (e) {
        console.log(e.message);
    }
});
return false;
};
コントローラーの配列から「国」の値を受け取ることができません。どうすればいいのかわかりません。
私のmysqlデータからすべての配列を返します:
{"success":"success","id":"38","country":[{"id":"38","type":"1","country":"1","event":"RAFAEL NADAL vs NOVAK DJOKOVIC","date":"2013-07-24 00:00:00","selection":"Novak Djokovic +2.5","odds":"1.83","result":"1"}]}
配列から要素を 1 つだけ取得するにはどうすればよいですか? 私は自分の国の値が欲しいのですが$array['data']['country']、コントローラーに入力すると (object Object) が得られます