1

I'm currently managing an e-commerce website that I did not develop. The developer chose to make it so that when you're viewing an item, clicking the "Add to Cart" button uses jQuery's "post" method to post the item's ID and the specified quantity to "/items/ajax_add_to_cart" via Ajax.

I got a report from the website's owner that two or three customers said that they were adding items to their shopping cart but that their shopping cart appeared to be empty. I investigated and found the following entries in the Apache access log (IP address and URLs changed):

127.0.0.1 - - [19/Sep/2011:12:49:50 -0400] "GET /items/view/1234 HTTP/1.1" 200 12117 "http://www.example.com/items/search/[keyword]" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0)"

127.0.0.1 - - [19/Sep/2011:12:50:15 -0400] "POST /items/ajax_add_to_cart HTTP/1.1" 200 15 "http://www.example.com/items/view/1234" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/5.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; BRI/1)"

127.0.0.1 - - [19/Sep/2011:12:50:16 -0400] "GET /items/view_cart HTTP/1.1" 200 10305 "http://www.example.com/items/view/1234" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0)"

Notice that when the "/items/ajax_add_to_cart" page is accessed, the user agent string implies that Internet Explorer 9 automatically went into Compatibility View. That explains why the cart ends up being empty. I'm not able to replicate this at all, though.

Any ideas on why this is happening? I will probably add the <meta http-equiv="X-UA-Compatible" content="IE=Edge"/> tag to fix it, but I'd like to be able to reproduce the problem first just to be absolutely certain of what's going on.

Nick
  • 8,049
  • 18
  • 63
  • 107
  • I know you changed the IP address, so the one you've quoted is not the real user address, but note that IE9's default configuration is to render using compatibility mode for sites in the 'local intranet'. Since you haven't specified the actual IP address, I don't know if this is the issue here. This can be switched off in browser config or overridden using the `http-equiv` meta tag or HTTP header. – Spudley Sep 21 '11 at 20:02
  • @Spudley I appreciate your help, but that doesn't appear to be the issue. I know that you can add a domain to the "local intranet" zone, but I don't think you can add a specific page (http://www.example.com/items/ajax_add_to_cart , in this case). It's like IE9 naturally goes into Compatibility View on that page, but only for those two or three users. – Nick Sep 21 '11 at 21:28
  • I had my doubts, which is why I posted it as a comment rather than as an answer. But it was the only thing I could think of. Only other thing I can suggest is checking your HTML validity with the W3C Validator. But I guess the big question is why would an Ajax even have any impact on the browser mode? Ajax events don't [shouldn't] cause the page to refresh, so they shouldn't change the browser mode at all from what it was already. – Spudley Sep 22 '11 at 08:09

1 Answers1

4

I have recently been asked to rescue two sites where IE9 has automatically gone into Compatibility View. In both instances the issue was a single line of CSS. Almost unbelievable. The CSS in both cases was valid with correct syntax. The first was a font declaration, the second a font-family declaration. Both contained a font stack. Removing the line fixed the problem. So, ths may well not be the answer you're looking for, but I'd say check the CSS!

apeBoy
  • 63
  • 7
  • This is very interesting. I'm stuck with a similar problem, and hadn't thought of looking at the CSS. I know you posted this almost a year ago, but may I ask, were you using custom font embedding in those websites? – Rorok_89 Oct 15 '12 at 08:41
  • It happens due to Type 1 fonts not being supported on IE9 and IE10. Refer: http://bobbyjoneswebdesign.blogspot.com/2011/12/internet-explorer-9-type-1-font-bug.html http://stackoverflow.com/questions/15011653/internet-explorer-automatically-switches-to-compatibility-mode-ie9-and-ie10 – webextensions.org Feb 21 '13 at 20:35