How to create a module to process AJAX request? I want to create a module to process some AJAX request like this:

$.ajax({
    url:'/?q=mymodule/path',
    dataType:'json',
    type:'POST',
    data:{'key':'abc', 'value':'123'},
    success:function(data){
        /*do somthing*/
    },
    error:function(){
        /*do somthing*/
    }
});


So which hook function should I implement?
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.