How ajax works:
it start an HTTP connection with the server and sends a request, but since it is not synchronous, it does not wait for response. Once the response comes, which is an XML. it invokes the function. Remember, since the reponse is usually an XML the call it ajaX. But it can also be a plain text.