Friday, 5 August 2011

The Spring MVC-Ajax Sample and its JSON Library

The Spring-MVC sample code is available from the Spring subversion repository at The idea of this sample is to demonstrate a simple Ajax application that updates an account screen both checking that a user name is available and adding a new account to the application.

The sample, which focuses on the Spring MVC code, is fronted by a JSP that uses JQuery together with a JSON JQuery javascript called ‘json.min.js’, which is somewhat anonymous.

It turns out that this code was written by Douglas Crockford and can be download from and is referenced from the JSON Website. This isn’t, however, the original code, it’s been hacked and had a couple of methods added:

$.fn.serializeObject = function() { etc

$.postJSON = function(url, data, callback) { etc

It could be argued that in a ‘real’ application, it’s not a good idea to modify other people’s libraries as this prevents you from taking and using their updates, but hey, this is only sample code.

No comments: