How do I create an AJAX callback to Drupal video link? We have a number of videos which are hosted locally and are simple HTML5 video tags. We want to keep track of play clicks. So to be clear, we don't want to track clicks on the URL, we want click tracks on the video tag.

So I want to write a little jQuery() to get the onclick() and then call a Drupal function to update a Drupal entity to store the # of clicks and their source.

I've written AJAX in other environments (PHPBB, Wordpress) but not Drupal. I guess I'm looking for a 'starter kit' which demonstrates interfacing Drupal CRUD functions with js.
You need a route and callback defined in a hook_menu. Below is a kickstarter not a complete example ;)

function example_module_menu() {
  $items = array();

  // an endpoint to add an entity to the default flag_list
  $items['node/%/play'] = array(
    'page callback' =&gt; 'example_module_video_count',
    'page arguments' =&gt; array(1),
    'access callback' =&gt; 'user_access',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK,
    'delivery callback' =&gt; 'ajax_deliver',
  );
  return $items;
}


Here is the callback

function example_module_video_count($nid = NULL) {
    /* do you stuff */
    $node = node_load($nid);
    $commands = array();
    /* add some ajax commands if required, look at ajax_command_invoke */
    return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);    
}


Hit the URL from jQuery.ajax()

$.post("/node/1/play", function(data) {});