Add Comment
Ajax is Easy with CFAJAXPROXY Tutorial
ColdFusion Tutorial #13
How hard is doing Ajax? Well with ColdFusion 8 it's easy, very easy. This tutorial, shows just how easy it is to call CFC methods both without and with paramaters. Not only is it easy, the calls are quick, if you haven't tried Ajax, this is a must read.
In case you are not sure what Ajax is, it's the ability to communicate from the browser back to a server, without the need for page refreshes. The Ajax calls can also return values, so you have two way communication. You will notice that the results of the buttons in the demos are very quick and the browser does not refresh.
demo.cfm
The key to this whole thing is line 1. This setups a Javascript proxy to a CFC, in this example i've named the proxy the same as the CFC.Then all you do is using javascript create an instance of the CFC proxy, then you can just call it's methods, it's that simple.
Line 5: Create the instance
Line 6: Setup the function name that will get called upon a sucessful call
Line 7: Call the method
Then the function starting at Line 10 gets the results and simply populates a div with the contents.
The second function, is the same but demonstrates passing a paramater, very easy.
Have a look at the demo to see it all working.
proxy.cfc
The cfc is just a normal CFC, only requirement is that the methods you wish to call have an access type of "remote". It's that simple, no tricks or magic.How easy was that.
Demo
See this code running!
Download
Download this code as a zip!
Comments
Esta muy bueno el código, ya que permite usar AJAX sin tanto problema.Cool Source Code.
Ya lo modifique y sirve de maravilla.
Gracias
avefenixtab @ Sunday 23 Mar 2008 - 02:05:54 AM
Anyone who buys that it's that easy hasn't tried to apply it yet. Try it with cfgrid. You'll find that Adobe has left it blowing in the wind.
vaughn @ Wednesday 26 Mar 2008 - 01:32:59 PM
Click button to add a comment
Author
Dale Fraser