How to pass node ID argument to Drupal 7 div auto update ajax script
I probably would have done this differently but than again I'm not a hundred percent sure what you are doing.

In response how can you pass the node id to javascript. Perhaps in hook_page_alter():

$node = menu_get_object();
if ($node) {
  drupal_add_js(array('your_module_name' =&gt; array('nid' =&gt; $node-&gt;nid), 'setting');
}


Then in your ajax code get the nid via:

Drupal.settings.your_module_name.nid