I’m trying to post data from ajax to php page which I made in the hook_menu, called “handler”. So I have “domain.com/handler” which I try to do this in it:
function handler(){ print_r($_POST); }
and the hook looks like this:
$items['handler'] = array( 'title' => 'Handler', 'description' => 'handler for File Upload', 'page callback' => 'handler', //'access arguments' => array('access my_module_name via ajax'), 'access arguments' => array('access example ajax'), 'type' => MENU_CALLBACK );
and on my js file i do this:
$.ajax({ url: "/handler", type: "POST", dataType: "json", data: {"name":"John","location":"Boston"} })
and its wrapped inside Drupal.behaviors.mymodule = {…} when I run the ajax, the response I get is an empty array. why don’t I receive the data?
Sponsored by SupremePR