从模型中获取数组 - >在控制器中编辑数组 - >通过json发送到codeigniter中查看

时间:2011-10-24 10:44:20

标签: jquery ajax json codeigniter

当我从我的模型中得到一个数组时,就像这样

function get_sites() {
    echo json_encode($data['usersites'] = $this->usersites_model->get_user_sites($this->session->userdata('account_id')));
}

这完全发送到我的视图,除了我在数组中有一个URL,我需要在将其发送到视图之前进行urldecode。

如何在发送之前编辑数组呢?

我试过了

function get_sites() {

    $data['usersites'] = $this->usersites_model->get_user_sites($this->session->userdata('account_id'));

    $data['usersites'] = array (                
        $data['site_id'] = 'site_id',
        $data['site_title'] = 'site_title',
        $data['site_url'] = urldecode('site_url'),
        $data['site_description'] = 'site_description',
        $data['site_category'] = 'site_category'
    );

    echo json_encode($data);
}

function get_sites() {
    $data['usersites'] = $this->usersites_model->get_user_sites($this->session->userdata('account_id'));
    $data['site_id'] = 'site_id';
    $data['site_title'] = 'site_title';
    $data['site_url'] = urldecode('site_url');
    $data['site_description'] = 'site_description';
    $data['site_category'] = 'site_category';
    echo json_encode($data);
}

0 个答案:

没有答案