Nov 17, 2010

jQuery or CFAjaxproxy ColdFusion AJAX

We use cfajaxproxy quite alot but they way our application is structured we have to do some special tricks to force existing methods to run correctly as we reference so much from the application scope.  Lately I have been thinking about how we could avoid this and make use of jQuery for all our ajax.

On some of my personal sites and other side projects I ahve used jQuery for all ajax calls and its really quite nice and friendly to work with.

While cfajaxproxy is quick and easy it's also a little heavy and forces us to re-setup the application to run correctly in our application.

What do you think? and what are you using?

17 comments:

  1. I'd suggest jQuery.

    One of the many great things about CF is that it allows almost anybody to develop web apps quickly. If you need to implement a slick looking popup window and you don't know JS (jQuery, ext, mooTools, whichever), cfwindow works a treat.

    But one of the side effects of "simple" is that it's limiting. There's only so much you can do with the "out of the box" functionality. For many, that functionality may be adequate.

    Before I got into jQuery, I thought cfAjaxProxy rocked (even wrote a blog entry about it). Now that I"m familiar with jQuery though, I'd prefer to do the "heavy lifting" myself and know that whatever needs to be done, I can do. I'm not limited by the simplicity.

    ReplyDelete
  2. Thanks Charlie. I agree jQuery is totally portable. I also remember your jQuery and ColdFusion demos of http://www.learncf.com - http://tutorial44.learncf.com/

    ReplyDelete
  3. if cfajaxproxy works, keep using. Less JS to maintain is always good.

    ReplyDelete
  4. @Henry Sure it works but that's not the point. If you have used cfajaxproxy you'll find that you do actually have to write alot of your own JS function the same as if you used jQuery. Personally I don't see it as suing a great deall less js then coldfusion alone.

    ReplyDelete
  5. I use both. We use cfajaxproxy to bind to CFCs then utilize those objects with jQuery functions. I have two pages that I've built that mixes and I found that I really mixed the two together pretty well and they've become very complimentary features.

    ReplyDelete
  6. jQuery - you can know exactly what is going on. I use it with my CFCs with returnformat=json. The only pain if CF pretty much returns all data as strings - even with CF9.0.1 update.

    For me Adobe could get rid of all the client side stuff in CF and focus on making it lean/fast and handling heavy lifting/services etc.

    If you take a look at something like the file uploader in CF it is huge - over 100k as I recall. That's just silly stuff.

    ReplyDelete
  7. We use both - AJAX Proxy to set up the initial links and then jQuery to utilise them. We're moving more towards pure jQuery though as time progresses just to avoid loading 2 lots of Javascript libraries.

    ReplyDelete
  8. We use both as well. I like the ability to have JQuery interact with the proxy CFC seamlessly. It is a cool way to develop, mixing CFC classes with JS.

    ReplyDelete
  9. Have no problem with CFAjax and Jquery too. But I use CFJAAX

    ReplyDelete
  10. There is no solution to getting around the application scope issue you describe. But first lets look at cfajaxproxy, this is using the same ajax request that both ExtJS and jQuery use.

    So whether you are going with ExtJS Core, or YUI, Dojo, jQuery or any other framework you will have the same problem as they all use the same http ajax protocol.

    So regardless of your solution in the long run, you will still have the same problem when dealing with using the application scope.

    ReplyDelete
  11. Usign jQuery to a cfc thay resides in the root will give full access via ajax to the application scope. cfajaxproxy will also give access to the app scope as long as the cfc resides in the document root ( ie not a mapping ).

    Either work well but jQuery is more portable.

    ReplyDelete
  12. Paul they all use XMLHttpRequest, and they all will have the same problem with creating a new session.

    ReplyDelete
  13. The all create a new application session.

    ReplyDelete
  14. Well my comment got chopped some how.

    So here it is again.

    When dealing with cfajaxproxy there are certain conditions that WILL create a new session (not Application but browser session). As CFAjaxProxy uses XMLHttpRequest() as does ExtJS, ExtJS Core and jQuery they all will suffer this problem.

    ReplyDelete
  15. A browser session is not a application session so I'm really not sure what your point is Andrew.

    With the way our application is setup we can NEVER fix this with cfajaxproxy and the way it handles virtual directories but we could with jQuery.

    ReplyDelete