You are here

Ajax

Cross Domain Access to JSON Data Returned by Drupal's Hook Menu

In this article I will talk about how I access JSON data processed by a Drupal Hook Menu's page callback from a remote domain. The idea here is that sometimes we want to take advantage of Drupal powerful Hook Menu (hook_menu) system to register paths and handle the processing of data for that page request.

HOOK MENU

hook_menu

First, I'll add a menu item so that we can register the path that when access will return an object in JSON format. for this example, I will use the name mymodule to refer to the module where all the code will be saved.