Timeline of a bugfix

2:00pm (yesterday): While reviewing site changes with our designer one day prior to launch, I noticed that the shopping cart functionality was screwed up. Badly. The site is using Commerce for Drupal 7, and when you change options for a product prior to clicking “Add to Cart”, it’s supposed to refresh the form with new details and an updated price. Instead, the form disappears. Obviously, this can’t be launched and fixed later. Continue reading Timeline of a bugfix

How to AJAXify any POSTed web form

Probably not too practical in real life, but I wanted to see just how easy it could be to implement this. If you want a lazy way to automatically convert any normal HTML POST form (send email, submit information, etc.) into a quicker-looking AJAX form, here’s the quickest way to do it:
Continue reading How to AJAXify any POSTed web form

Caching Google Maps geocoding lookups

Google Maps geocoding — the ability to send an AJAX request with a street address and get back a specific latitude and longitude (and lots of other data) in response — is a very useful tool for any number of mapping applications. Best of all, these applications can be written in pure JavaScript — but at a price. Google has strict usage limits for its free geocoding service, which can only be increased for a fee.

However, if your application tends to hit the same addresses over and over again — say, to plot the location of restaurants near your business address — it’s possible to cache these lookups in a database. You’ll still be using Google to look up new addresses, but any user hitting the same address twice in the same day will use your database instead of Google’s service. Continue reading Caching Google Maps geocoding lookups

Geocoding with Google Maps without OVER_QUERY_LIMIT errors

Problem: A JavaScript application needs to do more geocoding lookups than Google will let you do at once. It’s possible to use setTimeout() to make JavaScript wait, but with the callbacks, it’s cumbersome.

Solution: Use a server-side script that will retrieve the same data, requesting it over and over if an OVER_QUERY_LIMIT error occurs.

Continue reading Geocoding with Google Maps without OVER_QUERY_LIMIT errors