Futurama: “Bender’s Game”

“Futurama” unfortunately never got the love that “The Simpsons” gets, but I’m still grateful for the fact that Fox gave the show another chance in the form of four direct-to-DVD releases (“Futurama – Bender’s Big Score”, “Futurama: The Beast with a Billion Backs”, “Futurama: Bender’s Game”, and the forth-coming “Into the Wild Green Yonder”).

All I really know about “Bender’s Game” is that it involves D&D, robots and Leela as a centaur. It being “Futurama” was enough to know that I wanted to see it; that’s all icing on the cake.

Continue reading

WebDev: jQuery, JSON, IE and Caching

I’m almost ready to update the production version of UVFood.com. I’ve been testing against Firefox during development, but I can’t possibly deploy the update without testing against other browsers. Safari turned up no surprises, and Opera has turned up a weird little problem that doesn’t make any sense.

But of course it was Internet Explorer that had the biggest issues.

Bookmarking is done via Ajax. When you bookmark a listing the icon changes from a heart with a plus sign to a heart with a minus sign, the count of the number of times the the listing was bookmarked is updated and a message is displayed that confirms the item was bookmarked. This works fine with Safari, Firefox and Opera. Internet Explorer, however, exhibits some truly erratic behavior. When you bookmark a listing in IE everything you expect happens. But when you click again to remove it from the bookmarks – everything that happened the last time happened again.

Entering a review worked, though. But clicking stars to rate a listing had a similar problem.

The problem was that jQuery on IE was caching the JSON results, something it wasn’t doing on Safari or Firefox.

The first thing I tried was to make sure that my server returned a header in the response to tell the client not to cache the results. It’s a simple header line:

Cache-Control: no-cache

Unfortunately this didn’t change anything. It’s still good practice to make sure that your server emits the correct cache control headers, though.

Then I remembered a discussion of jQuery and GET vs. POST methods. GET is meant to be idempotent, no ill effects if it’s repeated (a request to move to position 8 is idempotent; a request to move to the next position is not). And it may be okay to store the results of a GET. POST is meant to be used for other requests.

Unfortunately, the convenience function that jQuery offers for dealing with jSON Ajax requests is getJSON(), which uses a GET request. It’s easy to write a postJSON() convenience function, however. Just add this to your jQuery initialization code:

$.postJSON = function(url, data, callback) { $.post(url, data, callback, "json");

Changing my code to use postJSON() instead of getJSON() solved the problem.

Offline jQuery Documentation for MacOS X

I’m rewriting UVFood to use jQuery instead of Prototype. I’m liking jQuery quite a bit and my code’s looking much better (and tighter).

I don’t always have reliable online access when I’m coding – in particular, I was on a bus today for a couple of hours and didn’t always have Internet access. There are a couple of dashboard widgets for MacOS X which I found that helped out on the jQuery documentation front.

First, there’s http://code.google.com/p/jquery-reference/. This widget is designed for browsing… click around in it, but don’t expect to search it.

Then there’s also http://blog.medallia.com/2007/05/jquery_reference_widget.html. This widget is designed for searching – if you know what you’re looking for, you can find it quickly.

They’re both useful in different ways, and I used them both this afternoon.

LJ Crossposting

I have a bunch of half-written things that I haven’t finished because I haven’t been happy with the state of cross-posting between this blog and Livejournal and I haven’t really had the time to deal with fixing it.

I’m cross-posting to make it easier for friends on LJ to read my blog entries. I find that using LJ to follow friends is a great feature; it’s what keeps me coming back to LJ.

It looks like I have it working now. I currently have it set up to cross-post everything. I’ll be writing a lot more technical articles in the near term, with some non-technical stuff mixed in. If you’d rather that I didn’t cross-post, or didn’t cross-post everything, let me know and I’ll see what I can figure out about limiting it.

I have cross-posting set up to require that comments be left here instead of on LJ. If you want to comment, you can use OpenID to login – instead of creating an account, just use the OpenID option on the account creation page. You can then authenticate yourself with Livejournal and not have another account to keep track of.

Continue reading

%d bloggers like this:
var _gaq = _gaq || []; var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js'; _gaq.push(['_require', 'inpage_linkid', pluginUrl]); _gaq.push(['_setAccount', 'UA-239812-12']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();