Aliaspooryorik
ColdFusion ORM Book

jQuery 1.5 broke my validation

jQuery 1.5 includes a complete overhaul of the AJAX module. However, it broke the validation jQuery plugin remote calls that ValidateThis uses.

Whilst debugging it in Firebug, I noticed that a new "callback" parameter is passed to the server, which you didn't have with jQuery 1.4.4. After a bit of googling I found a comment on a mailing list that you need to include this callback in your server response.

Previously, the server side script just had to return true or false, so this worked fine:


<cfset result = "true">
<cfoutput>#result#</cfoutput>

With jQuery 1.5, you need to do this:


<cfset result = "true">
<cfoutput>#url.callback#(#result#)</cfoutput>

Hope that saves someone some head scratching!

Update: This is fixed in the jQuery plugin repo on github: 

https://github.com/bigfix/jquery-validation/commit/9aa53f9241224ba349f9fe1b2c801be0f431b63b


6 comments

  1. John, I'm a bit confused - it this specifically for JSONP stuff?

    Comment by Ben Nadel – February 15, 2011
  2. Hi Ben, The validate plugin uses an extended version of $.ajax so I think this only happens if your using the plugin as I haven't had any other issues... yet! :)

    Comment by John Whish – February 16, 2011
  3. Ahh, gotcha. Ok, I thought you meant it was treating the return data in some new fashion. Good stuff.

    Comment by Ben Nadel – February 16, 2011
  4. Hi, i am having the same issue. From stackoverflow: stackoverflow.com/questions/5074920/remote-validation-of-jquery-validation-plugin-is-breaking-in-jquery-1-5 , i came here. I am not able to understand what you are returning. Now, i am just returning string value from my java servlet. Do i need to make changes in client side or server side?!

    Comment by Tamil Vendhan K – February 22, 2011
  5. @Tamil,

    This is now fixed in the jQuery plugin repo on github:

    https://github.com/bigfix/jquery-validation/commit/9aa53f9241224ba349f9fe1b2c801be0f431b63b

    Comment by John Whish – February 22, 2011
  6. Woot; Thank you so very much!

    Comment by Paco – September 19, 2011

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments
 

Search

Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)

Categories

Recent Posts