In my example I have four files:
example.html = the html page that gives the user two buttons that fire off asynchronous calls to a server side script.
AsyncManager.js = The prototype (aka. class) that handles communication and response. It also updates a div element with status information.
asyncreceiver.php = The server side script written in PHP that handles two example requests from our AsyncManager.js. In this case it sends back a timestamp or random number in a requested range.
example.js = The client page script that starts the request and handles the final response from the two example requests.
Here is the AsyncManager.js:
Here are a pair of functions from example.js that call and receive from AsyncManager: