I was just talking to John Ramon about an odd issue he was having with Internet Explorer and Ajax. His code was incredibly simple and worked fine in Chrome but not IE. Here's a quick example of how simple his code was:
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#spot").load("test3.cfm");
})
</script>
</head> <body> <div id="spot"></div> </body>
</html>
<html>
As you can see, all this code does is load the page and make an Ajax request to load test3.cfm. When I tested his site in IE9 it worked fine. I then found a machine with IE8 (yeah, cuz lord forbid a web developer be allowed to run IE8 and 9 on the same machine without creating an entire operating system virtual image as opposed to just freaking running two apps but I'll stop the sermon now) and it also worked for me fine there!
Turns out the issue was ColdFusion debugging! That's why it worked fine in my IE and not his. He had his debugging restricted to just his IP so I never saw it. Now here's where things get interesting. Those of us who use Ajax and ColdFusion are used to disabling debugging since it breaks JSON responses. But in this case it should not have mattered. ColdFusion's debugging HTML would have just been added to the end. And in fact, when I turned on debugging and ran the page in Chrome, I just saw 2 copies of the debugging info. One from the "main" page I ran and one from the page loaded via Ajax. But in IE (and that includes IE9) I was able to replicate it as well.
My guess is that the closing </div> tag output in the beginning of ColdFusion's debugging output broke IE's DOM when it was inserted into the div. This is - probably - IE being a bit more strict than Chrome.
As one last reminder - you can easily use ColdFusion debugging and turn it off on a per request basis using:
<cfsetting showdebugoutput="false">
Archived Comments
Don't forget you can also append _cf_nodebug=true to your individual Ajax URLs to disable it on a request basis. I use that often by setting a baseURL in JS (foo.cfm?_cf_nodebug=true) that I use in all my Ajax requests - that way I can open the URL in another tab to view the response directly and also have access to the debug output in another browser tab.
The issue is that I _never_ remember that.
The funny thing is that every time I use it I have to google for the exact syntax because I always forget exactly what it is.
Good looking out Todd ...
That's a subtle one to remember ... ;-)
What happens when you use the IE emulation functionality of IE9 (http://msdn.microsoft.com/e... Just curious.
SteveW: Didn't seem to help.
Note that you can use IETester to test in old versions of IE pretty well: http://www.my-debugbar.com/...
As Steve points out, IE9 has modes to IE8 and IE7 too, but I'm not sure if that would catch everything.
Thanks Raymond!
Now there are three statements that I'll be adding to the top of all my remote components:
<cfsetting showdebugoutput="false">
<cfcontent type="application/json">
<cfparam name="url.returnformat" default="json">
Run multiple versions of IE at once without the need for a virtual machine www.my-debugbar.com/wiki/IE...
I have DebugBar installed and it's not very useful. It crashes all the time and doesn't always render as IE would. It's a good tool, but it would still be nice to be able to run multiple versions of IE at the same time.
Not sure if this is helpful to anyone, but if you get the IE10 Platform Preview, and choose the debug option from the menu, you can change the document modes and browser modes (IE7-10) easily in the debug -> developer tools. Lessens the need for having IE8 on a VM or 2nd machine
I believe you spelled "sermon" wrong.
Fixed, thanks.