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 :)

SVN/CVS: Any good Commit Comment templates?

We're implementing SVN in our office and well, things are well under way.

However, people are going to start committing their changes in various ways. So reading commits from multiple developers (might) prove to be confusing.

I was playing around with SVN for eclipse and it's got a great feature called, "Commit Templates".

Being new, I created 2 templates for myself and was thinking about making Commit Templates a standard among the developers.

Here's what I made up so far:

=BUG FIX=

Bug Description:

Fix:

Project:


=NEW FEATURE=

Description:

Project:


Again, these are just for me. I was wondering if anyone else has any other templates that you use and like?

Thanks!

jQuery + ajax + logout form

I love jquery! Let me just say that now. I'm a true convert from prototype/scriptaculous. I love prototype for all it's pros. But, I can't deny the support from the jQuery community and the momentum it has in the web world.

With that said, I dove in and started playing around with the jQuery UI plugin (built by the jQuery guys of course). The dialog plug in is simply DOPE!! (is that a youngin' term?)

I was playing around with a logout confirmation dialog and here's what I've come up with. It's a bit verbose for my taste and by NO means the best way to do this. But, I do hope it points people in the right direction if they're looking to do something like this.


$('#logout').click(
        function(e){
        e.preventDefault();
        
$('<div id="confirmLogout" title="Logout?">Are you sure you want to log out?</div>').dialog(
            {
            modal: true,
            height: 100,
            width:350,
            show:"blind",
            hide: "blind",
            buttons:{
                "Yes":function() {
                    $.ajax({
                        url: 'someActionCall.cfm',
                        complete: function() {
                            $('#confirmLogout').html("See you next time!");
                            $('.ui-dialog-buttonpane').css('display','none');
                            var dlg = $("#confirmLogout").parents(".ui-dialog:first");
                            dlg.animate({ width: 200},50);
                            setTimeout(function(){$("#confirmLogout").dialog("close")},3000);
                            setTimeout(function(){location.reload();},1500);    
                            }
                        });
                    },
                "No":function() {
                    $("#confirmLogout").dialog("close");
                    }
            },
            close:function(){
                 $("#confirmLogout").remove();
            }
            });

return false;
    });


The demo can be found here: Logout demo

Calendar

NAVIGATION

Recent Comments

RSS

Search

Subscribe

Tags