How to get pure json data by ajax request

原创
2012/05/13 23:13
阅读数 141

jquery:
//enabled clean url
$.post(url + 'workitem/get_json_data');
//else
$.post(url+'?q=workitem/get_json_data');

drupal backend:
function hook_menu() {
    $items['workitem/get_json_data'] = array(
            'page callback' => 'get_data',
            'delivery callback' => 'get_data_delivery',
            'access callback' => TRUE,
            'file' => 'model.inc',
            'type' => MENU_CALLBACK,
    );
    return $items;
}
function get_data(){
    return array();
}
function get_data_delivery($result){
    drupal_json_output($result);
}
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部