Hit a major bummer while updating the Punk widget today. Essentially, the onreadystatechange handler will miss the redirect/Location: (302) header being sent. IMDb uses 302 when there’s only one search result and catching that was a really nice shortcut instead of having to parse the page to find out what has happened. The widget used curl before with which it’s super-easy to notice these things, but for some other reasons, I had already re-written everything to use XMLHttpRequest.
It really seems that, in my case, the “easiest” thing to do is just taking a peak at the page title. With IMDb it’s easy - it’s “IMDb Title Search” whenever there’s more than 1 result.