Rob Gonda's Blog

ajaxCFC synchronous form validation

Now for the synchronous advantages, I created an example that shows one of the advantages for synchronous ajax. Upon form submission, a simple JavaScript code check for required fields and alerts a single message with the errors summary (try submitting a blank form).

If the email is provided, an ajax call makes sure the user doesn't already exist. Emails are stored in the session, if you try to create the same email more than once, the JavaScript alert will inform you that the email already exists. The advantage of the call being synchronous is that is can be incorporated with the rest of the form validation.

This process is doable with asynchronous ajax, but the only way to do it is for the form validation to always return false, and the call back function re-submit the form if appropriate. This process start becoming tedious if you need to validate several fields, such as address, email, captcha, username, and any other you may think of. The only way would be that each ajax call had to be initiated in the call-back from the previous call, in a cascade fashion… then also storing all the different results if you wanted to display a single error alert summary.

by the way, I added the multithreaded example and this one to the ajaxCFC download.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?18EA7853-3048-7431-E4BE5961609BC6CC

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
This blog is running version 5.9.003. Contact Blog Owner