HTML in AJAX requests break in Internet Explorer 8 and 9

54 views
Skip to first unread message

in...@monstergardens.com

unread,
Mar 16, 2015, 7:28:59 PM3/16/15
to mod-pagesp...@googlegroups.com
I am running into some problems with the HTML tags being excluded in AJAX calls in Internet Explorer 8 and 9.  I had my host enable Modpagespeed but did not change any directives so the defaults should be running.  You can see the problem here after you select a country it should populate the "Region / State" select box after an AJAX call, but in Internet Explorer 8 and 9 the HTML tags disappear.  When I turn Modpagespeed off with the "ModPagespeed off" in my htaccess file it starts working again in IE.  Has anyone ever run into this problem?

Joshua Marantz

unread,
Mar 16, 2015, 10:12:07 PM3/16/15
to mod-pagespeed-discuss
I'm not sure what the default set up is for your host.  Who is your hosting provider?

I have a theory as to what's going on, but I don't have convenient access to IE 8 and 9 at the moment.  On Chrome, XHR requests are sent with request-header:
  1. X-Requested-With:
    XMLHttpRequest
My theory is that for older versions of IE, that header is not sent with the XHR request, which means that mod_pagespeed does not really know that it's an XHR request it's responding to. One implication is that it may insert some JavaScript helper functions into your HTML. You can't do anything about this (other than disable some mod_pagespeed filters) because you can't fix IE8 and IE9.

However, I've also noted that your server sends the following with the XHR response:
  1. Content-Type:
    text/html; charset=utf-8
This does not look right.  Can you change it to text/xml?  That will prevent mod_paegspeed from messing with the XHR response at all, and I think that might be the easiest and best solution.

-Josh

On Mon, Mar 16, 2015 at 7:28 PM, <in...@monstergardens.com> wrote:
I am running into some problems with the HTML tags being excluded in AJAX calls in Internet Explorer 8 and 9.  I had my host enable Modpagespeed but did not change any directives so the defaults should be running.  You can see the problem here after you select a country it should populate the "Region / State" select box after an AJAX call, but in Internet Explorer 8 and 9 the HTML tags disappear.  When I turn Modpagespeed off with the "ModPagespeed off" in my htaccess file it starts working again in IE.  Has anyone ever run into this problem?

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/bd2c43aa-f472-49ba-9dc5-6f3433034c8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

in...@monstergardens.com

unread,
Mar 16, 2015, 11:40:58 PM3/16/15
to mod-pagesp...@googlegroups.com
I fixed it!  Thank you for the reply Josh, it got me thinking about it and I found the solution.  I am blushing a bit for not figuring it out faster.  It turns out modpagespeed was inserting a </header> tag at the beginning of each XHR response.  That was screwing up old versions of IE but not other browsers.  I turned off the add_head filter and it is working perfectly now.

Joshua Marantz

unread,
Mar 17, 2015, 10:00:23 AM3/17/15
to mod-pagespeed-discuss
That doesn't sounds right.  First of all add_head is implied by a number of other filters, so turning it off probably won't help.

Really your XHR responses are not HTML so you don't want mod_pagespeed to treat them like they are.  It is fine to put <head></head> in HTML, and add script tags.  You probably don't want them in your XHR responses..  So the right thing is to change the response-header content-type to say text/xml and not text/html.

I suspect you will have other issues as well if you don't do this.

-Josh

On Mon, Mar 16, 2015 at 11:40 PM, <in...@monstergardens.com> wrote:
I fixed it!  Thank you for the reply Josh, it got me thinking about it and I found the solution.  I am blushing a bit for not figuring it out faster.  It turns out modpagespeed was inserting a </header> tag at the beginning of each XHR response.  That was screwing up old versions of IE but not other browsers.  I turned off the add_head filter and it is working perfectly now.

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.

in...@monstergardens.com

unread,
Mar 17, 2015, 3:12:19 PM3/17/15
to mod-pagesp...@googlegroups.com
That's no doubt excellent advice.  There are a few complications with the change and there is code like that in a few places.  I'm working on changing and testing it on a dev server. 

I can confirm though that adding "ModPagespeedDisableFilters add_head" to my root htaccess issue did solve the problem.  The "</head>" tag stopped being prepended to the response and the older versions of IE stopped borking.  Thanks for your work on mod_pagespeed, it's a really great tool!
Reply all
Reply to author
Forward
0 new messages