(Note to readers: I leave on vacation tomorrow, so I will be posting sporadically next week if at all. I expect to be internet inaccessible for a few days. My family will be in Phoenix and Las Vegas.)
Now that browser manufacturers are testing to a common set of standards, web developers can breathe easier. There are still browser quirks that need to be programmed around, but they are largely minor annoyances now. More importantly since these three components can be taken for granted at least 98% of the time it becomes possible for web browsers to do amazing things that used to require installing separate programs on your desktop computer. The logic to make it work in your browser gets a bit complex at times but it is possible to emulate most of the rich functionality of a desktop application inside the browser. Most web developers, however, have yet to dip their toes into this AJAX stuff. Until about a week ago, I was one of them.
I dallied because being a web developer is a very part time gig for me. My full time job is in Information Technology management, not in programming. You can make a programmer a manager but some part of the manager remains a programmer. On nights and weekends, I have been dipping my toes into the AJAX world. It is not entirely a waste of my time. I have a few practice domains where I can try this stuff out without embarrassing myself. What I learn I can often apply to my job. For example, we have a need to collect names and email addresses to run a customer satisfaction survey for the system that I manage. If we can avoid the overhead of having a page refresh, we can drop the form onto many of our web pages without disrupting their flow of business. This allows us to target particular kinds of system users so we can get a better response rate to particular kinds of questions.
I run two other domains. I use the Oak Hill Virginia site as my test bed. It is designed to be a community web site. While it does not get much in the way of traffic, judging from the ads served on my site by Google it is of interest to the real estate community. When I purchased the domain in 2001 there were little in the way of tools that I could use to integrate real estate content into my site. Fortunately, that has changed. Working with the husband of a local realtor, I became aware two sites. Zillow.com offers a home valuation service. Trulia.com offers a real estate search engine that can plop houses for sale on top of Google Maps. Both offer APIs, or Application Programming Interfaces. This means a developer like me can register to use their APIs and embed them in my web sites.
My first AJAX project was to integrate the Zillow.com home valuation service into my site. I did not want my page to refresh. I simply wanted someone to enter the address of a house and have its price unobtrusively appear on my web page. This could only be done using AJAX. My original hope was that I would not have to write any proxy script for my website to get the home price from zillow.com. Unfortunately, browsers have security mechanisms built in. Unless you specifically configure your browser otherwise, it cannot use the XMLHttpRequest object to call any other server other than the server that served the web page. (Not only that but the browser will assume www.domain.com is not the same server as domain.com.) Therefore, I had to create a proxy script on my server, which I wrote in PHP. It took the address and simply passed it on to zillow.com. It waited for a response from zillow.com then echoed back the value of the home. Zillow.com’s API, like most, uses a REST based XML service. It avoids the overhead of using SOAP. However, the lack of standardization in the REST world meant that I had to fine-tune my script to accommodate the eccentricities of the zillow.com API. Still, this was easier than dealing with the overhead of getting the data as a SOAP service.
Now could I write my own AJAX web service instead of relying on someone else’s service? I created a contact form where people interested in buying or selling property in my community could simply type in their information and it would be sent to a local realtor. This was not that difficult a service to create either. For both services, I found I wanted to record information received into a MySQL database table on my server as well as have the service send me an email whenever someone invoked it. Since I know MySQL and its programming API rather well this was not terribly challenging. In addition, PHP comes with a handy mail function, so it was also straightforward to have the services send me email. Eventually if the services prove to attract sufficient contacts, the contact information will go automatically to the realtor. Right now, I am reviewing content for spam.
AJAX applications like Google Maps are of course an order of magnitude more complex than my little AJAX applications. For most of us in the IT business though, we early our bread and butter through standard business applications like these. Eventually as time permits I hope to create a real estate page for the site, integrating the service from Trulia.com that lets me show local home listings in Google Maps, and serving related ads (mostly from realtors) around the content.
If you do a View Source on my oakhillva.com web site, you can see the client side logic I used. I have exposed my PHP server side code for my real estate leads service in this file. I had to obscure certain information for security purposes, of course.