I don't know how many times I've gone looking to do asynchronous processing in ColdFusion, and come up against the myriad of hacks, workarounds and that general feeling that I want to poke my eyes out with a rusty spoon.
Now that JavaLoader exists, integrating Java with ColdFusion becomes so ridiculously easy, it would have been relative heresy if I hadn't sat down for an afternoon and wrote a library for making asynchronous HTTP GET and POST requests.
To use the asyncHTTP library , you simply have to drop /asyncHTTP/ the folder in your web root, or create a mapping to it.
From here we create an instance of the AsyncHTTP.cfc:
asyncHTTP = createObject("component", "asyncHTTP.AsyncHTTP").init();
Now that we have an instance of the AsynHTTP CFC, to do an asynchronous GET request, we simply call:
If we want to pass form data across, we can also do an asynchronous POST request, like so:
formData = StructNew();
formData.var = "value";
That is it! It is as simple as that.