This is a really hard problem to put into a brief sentence, so I apologize if I kill it.
I launched a site recently which had been extensively tested on my local web server on all my desired browser platforms, including IE8 (IE8 standards mode, XHTML Strict). I encountered no problems at all until the site went live on a dedicated web server.
The site uses jQuery.get()
on the change
event for the input
elements of a form, where the response is grafted into a common <div id="results"></div>
.
Despite the caching woes I've read about with IE and XMLHTTPRequest, my problem seems to take place AFTER my ajax callback begins execution. My callback (supplied via .get()
/ .load()
-- I've tried both) receives an HTML fragment returned by my server. Testing the returned content in any browser reveals exactly what I expect the content to be.
However, as soon as I put the HTML fragment into the DOM tree in the #results
, IE actually clips the first 7 or 8 opening tags off of my markup (along with the children of most of those tags). It's wickedly bizarre. I fixed it in another area of the site by setting the HTML content via jQuery('#results')[0].innerHTML = content
, but no dice this time.
Example response:
<div>
<a href="#">some link</a>
<span>stuff, blah blah</span>
<a href="#">another link</a>
<ul>
<li id="item-2342">
<img src="#" />
<div class="info">
<h6> ..title.. </h6>
<a href="#">View</a>
<span rel="stats"> ..statistics.. </span>
</div>
</li>
<!-- ... and so on in a loop over items to create more <li> items ... -->
</ul>
</div>
Literally EVERYTHING up through the opening tag of that <span rel="stats">
is truncated. The effect is that IE displays my returned AJAX content as if it were to begin with the text node: ..statistics.. </span>
. (I tried removing the rel="stats"
at the suggestion of a comment below, changing it to a CSS class instead, but the same result occurs.)
If I request my AJAX url directly via the browser's URL field, the returned content is perfect.
If I use alert()
to display the AJAX content returned, it is perfect.
If I assign my AJAX content via .html()
or .innerHTML
, it is immediately truncated.
Sooo.... WTF? IE's (crappy) debugger displays no script errors or anything of that nature. Has anybody ever dealt with this kind of issue before? Again, I add emphasis to the fact that on my development server (127.0.0.1), IE has no problems, and it seems to use the same "mode" (IE8 Standards) and everything.
EDIT: Here is the Javascript powering the AJAX lookup:
jQuery('.ajax-panel').live('load', function(event, request_string){
var panel = jQuery(this).stop(true).fadeTo(100, 0.2).addClass('loading');
var form = jQuery(panel.attr('rel'));
jQuery.get(form.attr('action'), request_string ? request_string : form.serialize(), function(response){
// WTF?
// panel[0].innerHTML = response;
panel.empty().append(response);
// Carry on.
panel.removeClass('loading').stop(true).fadeTo(100, 1);
});
});