Thanks a lot! However 'HTTP_X_REQUESTED_WITH' did not work for me - I read that $_SERVER is not an official PHP request.
I went with my idea of sending an additional parameter with ajax (i. e. "&query=query"). The php-function outputs "echo" if the parameter "query" is set. Works perfectly!