Reputation: 23
I'm trying to implement a json endpoint via hook_menu. Here is my code:
function gcm_subscribe_menu() {
$items['gcm_subscribe/subscribe'] = array(
'title' => 'Test-Endpoint',
'page_callback' => 'gcm_subscribe_ajax_subscribe',
'type' => MENU_CALLBACK,
'access arguments' => array('access content'),
);
return $items;
}
function gcm_subscribe_ajax_subscribe() {
drupal_json(array('test' => 'testData'));
}
My problem is, that when i call this endpoint via javascript, i get an error 403.
Does someone know why?
Upvotes: 0
Views: 282
Reputation: 1
page callback is without the underscore, and in the callback function you should use return.
also, in d7 you shoud use drupal_json_output, instead drupal_json
Upvotes: 0