CFAjaxProxy or Javascript
I have been looking into AJAX technologies for my company recently. I am having trouble deciding between CFAjaxProxy and a Javascript (we use jQuery) call. IMO CFAjaxProxy is extremely easy to implement and jQuery is a little harder. Is there much performance difference between the two? Are there overheads that I might have overlooked? Are there any other options available for a ColdFusion environment?
EDIT
I 开发者_如何转开发don't know if i made my self clear. I was wondering whether CFAjaxProxy or javascript's XMLHttpRequest() object or jQuery's $.ajax() call is the best.
The answer is "Yes". Use both :). I use cfajaxproxy to get easy access to my CFCs, and I use jQuery to take the data that's returned and manipulate it to adjust the UI. You can see an example of that at http://www.lakehousesofamerica.com/america/searchforlandbymap.cfm. I use cfajaxproxy to pull data from a CFC that pulls properties from our database based on the viewport of the map. I then use custom javascript and jquery to manipulate the map based on those return values.
$.ajax() is a wrapper around the HTMLHttpRequest() object. I believe this is also true of CFAjaxProxy at a low level.
I don't think there is actually a "best" to this question. Personally, I use jQuery and $.ajax() more than either of the other solutions simply because it is the most portable (It doesn't care what it is talking to). Not a big fan of tying front end operations to the backend system, personally.
Whichever solution you choose make sure that you research the security implications it presents so you aren't opening your system up to much.
You have more control with jQuery as well as it scales better and you can always hit a CF page or a CFC, you can use jSon to serialize objects between server and client side. My team wrote a new feature we could of used anything we wanted, the pattern we chose was use jQuery for all Ajax communication between the UI and server side, the implementation was swift and can scale for many other platforms not just CF. We could swap out the server side at anytime, and the transition would be seamless.
精彩评论