How to create a module to process AJAX request?
If you are tying your functionality to Drupal, use Ajax framework commands
.

If you want to process any arbitrary incoming request, (ajax or otherwise) implement a Services resource.