How to make Ajax work for you

Really handy overview from Simon Willison130 slides about Ajax. Around about slide 58 he talks about the magical power of . If you’re still using XML to pass objects and data around, have a look at this.

I’ve been using JSON at work to open up our collections databases. The Collections Online search results pages are seperated into a controller script, which parses the URL for search query parameters and pass them off to the backend data model; a set of backend classes which run SQL and generate result sets containing the results; and a HTML view page which takes a search results object, loops through and displays the list of records. Fairly straightforward design. This gives me the flexibility to write new views of the data without having to muck about writing new SQL and data-processing code.

So I’ve experimented with writing a new view page (less than 10 lines of coldfusion code) which encodes the search results object as a JSON string. I’ve then added a module to our content management system which can read the JSON object and display it as a photo gallery. Kind of cool really – an object is instantiated in Coldfusion MX on one server, but then processed and presented by PHP running on a second server. JSON is very handy for these situations where you need to pass complex data structures between systems running on different application servers.

The next step, I think, would be to come up with some reasonable, standardised representation of collections records then open up our data with a standard JSON API that can be used by anyone.