I believe you are making this far harder than it should be.
Fundamentally, the web architecture was not designed to allow a
client to have asynchronous communications with two servers
My first choice would be to simply redirect the user to the remote
server, and have them redirect them back to my server when they’re
done. This is, for example, how PayPal works.
If that’s unacceptable, I would consider having your server act as a
proxy between the client and the remote server. So, you pass through
the clients request to the remote server, and then parse that remote
server’s response and present it to the client. You can make
everything AJAXy for the user, but our server has direct control over
In 4, I assume you meant to say: “The remote server send back a
normal http response.” You’d need to be more specific if you want
Dan K. mailto:[email protected]