I have two jsbin's illustrating the code:
http://jsbin.com/OdiSApI/1/edit This will hit an alert in IE8 - this alert is in a calling function, ExecuteSearch.
http://jsbin.com/OdiSApI/2/edit This seems to work fine in IE8.
Note: You'll need to click the Run with JS button in the top right pane. Then enter a city in the text field that's within the dropdown state and submit the form (this calls google maps geocode API).
The "fix" in the 2nd link is the following:
//account for asynchronous nature of IE XDR request
//geo_location is undefined here in IE8
//this seems to fix ie8, though I'm not sure why...
var timeout = setTimeout(function() {
clearTimeout(timeout);
}, 10);
The problem I was having is I'm having to use a XDomainRequest (XDR) for IE8-9 (partial CORS support). In the first jsbin, I'm hitting the alert in my ExecuteSearch function because my GeoCode function is returning before my xdr.onload is firing.
The timeout seems to be queueing my asynchronous XDR, though I'm not really sure what is happening and why that timeout seems to be my magic bullet here.
Anyone have any ideas?