blog | bio | agenda | jobs | ajaxCFC

AjaxCFC fastSerialize example

Due to popular request, I added an example showing how to easily submit an entire form through Ajax with the fastSerialize jQuery plugin.

All you require to do is to include this plugin:
$.AjaxCFC({require:'json,dDumper,blockUI,jquery.fastSerialize'});


and use it to send them form:
onSubmit="return send( $(this).fastSerialize() );"


the send() function looks like this:
    function send(frmData) {
        $.AjaxCFC({
          url: "echoTest.cfc",
          method: "echo",
          data: frmData,
          success: function(data) {
              sDumper(data);
          }
        });
    return false;
    };

simple huh?

Again, I updated the SVN repo and project download files. Enjoy.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?8E0A5A06-3048-7431-E4D6E4E6D36E5AA5

Comments
Hi Rob,

Sorry if I'm a little late on AjaxCFC, but how is this different to just doing a generic jquery .post?

$.post("echoText.cfc?method=echo", function(data){
alert("Data Loaded: " + data);
});
# Posted By Michael Sharman | 5/15/07 6:51 PM
@Michael, jquery indeed is poweful as it is, but AjaxCFC extends the client side functionality and add server side utils too. It allows seamless communication passing simple and complex arguments, adds logging, debugging, security, acts as a proxy so you dont have to expose your methods as remote, integrates with Model-Glue, MachII... you could do everything manually using jQuery, but it's a prepackaged solution to ease up your development. HTH :)

BTW, the $.post() function was deprecated with jQuery 1.1 in favor for .ajax().

Cheers.
# Posted By Rob Gonda | 5/15/07 8:23 PM
Why does this work:
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.AjaxCFC.js" type="text/javascript"></script>

but not this
<script src='../support/ajaxcfc/js/jquery.js' type='text/javascript'></script>
<script src='../support/ajaxcfc/js/jquery.AjaxCFC.js' type='text/javascript'></script>

ajax.cfc is in the support folder and works fine
# Posted By I Rz | 5/16/07 2:38 PM
@I Rz, there's not enough info to debug the problem. Care to share a link?
# Posted By Rob Gonda | 5/16/07 3:57 PM
I am just using your example. If the js files are in a directory under the code (js/js files) everything works. If I change the location of the js files to a directory above the code nothing works (../support/js/js files) even though the file are being included. On both tries the ajac.cfc is in the same place. Very strange and I have never seen anything like this before, even using straight jQuery without ajaxcfc.
It just seems that moving files around breaks things. Is this is why you put the cfcs in every directory? This isn't an include issue, the files are being included. Thanks.
# Posted By I Rz | 5/18/07 1:38 PM
The CFCs are in the same folder for the sake of ease in the example. The Ajax Facade has to extend Ajax.cfc, which if it does not reside in the same folder, you can still do with a CF mapping or full dot notation from your application root.

Can you specify where the code breaks and what error you're getting?
# Posted By Rob Gonda | 5/21/07 9:15 PM
Hey Rob, how do I pass config info to blockUI? Firefox says it 'is not a function' when I add

<code>
$.AjaxCFCHelper.setBlockUI(true);
$.blockUI ( {backgroundColor: '#ccc' });
</code>

?

Thanks
# Posted By Dennis Spaag | 8/6/07 12:19 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.