jQuery error() function not working in IE
===

I want to display two images that I have no idea when they will be generated. So I want to use the jquery error function to keep checking if the images exist, and display each. Following code works on every browser except IE. Why does it not work on IE, really appreciate your help.

    <script type="text/javascript">
	$(document).ready(function() {
		var image_names = new Array(2);
		image_names[0] = 'a.jpg';
		image_names[1] = 'b.jpg';
		var divs = document.getElementsByTagName("div");
		for ( var i = 0; i < divs.length; i++) {
			showImage(image_names[i], divs[i]);
		}
	});

	function showImage(src, div) {
		var img = new Image();
		$(img).load(function() {
			$(this).hide();
			$(div).removeClass('loading').append(this);
			$(this).fadeIn();
		}).error(function() {
			setTimeout(function() {
				$(img).attr('src', src);
			}, 2000);
		}).attr('src', src);
	}
    </script>

This is the HTML body

    <body>
	<h1>Image Loading</h1>
	<div id="loader" class="loading"></div>
	<div id="loader" class="loading"></div>
    </body>