Using Drupal menu system to handle AJAX posts

xurizaemon - December 8, 2008 - 11:24

I have a module ( http://drupal.org/project/jserrorlog ) which captures javascript errors by posting the error message back to a Drupal path.

Currently it works by using Drupal's hook_menu, catching the $_POST data sent via jQuery's $.post(), and then uses die() to avoid returning a themed Drupal page.

I'm sure there's a better approach, eg using xmlrpc.php (except, I don't need the form to return XML) or some other Drupal method for returning unstyled JSON data.

Input welcome!

 
 

Drupal is a registered trademark of Dries Buytaert.