Use AJAX without writing a module - D7
I'm sorry to say but, you are doing it wrong.

In some very few cases it could be worth not to write a module for an ajax request. The reason would be that you want to do something simple, not related to Drupal that needs to be very fast. I did this once for a site where I needed to look up if a domain name was registered or not.

In this case you are not isolated from Drupal. You need to know the context of your script (The node id) and you need to use the Drupal API's entity_load, so instead  of creating a custom PHP file and writing code in there, why not create a module which is a PHP file, only it's named foo.module, use the drupal API's to in make the ajax callback hook_menu, and add the javascript with context drupal_add_js and you will save yourself a lot of work, by doing things the Drupal way. Drupal is made it make it easy to develop stuff by creating modules, instead of adding custom PHP files, which makes things a lot more difficult to manage.

If you really wanted to do this without creating a module, you would need to bootstrap Drupal in your custom PHP file (making it pointless to use a custom php file), and add the node id in the preprocess_node hook in your theme.