jquery ajax + xml + IE = hair loss

I've done ajax before with jQuery with good results on all browsers...until

I used an XML return with IE (all IE's that is).

When returning XML from a CFC (or any other server-side script), IE doesn't treat the XML document as, well, XML.

It actually barfs on it unless you tell it to load up the ActiveX control to parse your XML doc. (psst..Thanks Microsoft).

Just look at this:


$.ajax({
type: "POST",
url: "ajaxtest.cfc?method=getallblogs",
data: datastring,
success: function(data) {
var xml;
if ( $.browser.msie ) {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(data);
} else {
xml = data;
}
$(xml).find('blog').each(function(){
var id = $(this).attr('id');
var title = $(this).find('name').text();
var url = $(this).find('url').text();
$('<div class="items" id="link_'+id+'"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#blogInfo');
});
}
});


See that little blurb in the ajax call for "if ($.browser.msie)"? That's the call you'll need to do to make IE behave like 99% of the other browsers out there.

I've put together a short demo. I know the code is duplicated, but this is for demo purposes. Hope this helps you guys doing XML data returns.

Oh and once again "Thank you Microsoft" for making my web development career such a wild adventure.

XML data return demo

p.s. the data returned is from my blackberry bloggers site. If you're a blackberry fan, check it out (http://www.blackberrybloggers.org). It might look a bit familiar :)

waving a one fingered gesture at Microsoft..wth?!

Ok..here's the situation...

I'm creating an HTML email with tables and background colors.

Lo and behold, if you nest tables, Outlook 2007 will strip out the background color. Wait...what? Yeah, exactly.

But, when you open the email in outlook and then view message in browser, voila! the background color emerges!

Thank you MS for using 2 different HTML rendering engines. One of the best cases of, 'the left hand doesn't know what the right hand is doing'

::: waving finger gesture :::

Calendar

NAVIGATION

Recent Comments

RSS

Search

Subscribe

Tags