I have the code below and what I need to do is load the image from the href into a div via ajax... Any help appreciated. I believe that load() can\'t load images like this?<
You have to also remove the currently appended image. Here it is with a click event and Image instead of appending markup.
$('#list li a').click(function () {
var url = $(this).attr('href'),
image = new Image();
image.src = url;
image.onload = function () {
$('#image-holder').empty().append(image);
};
image.onerror = function () {
$('#image-holder').empty().html('That image is not available.');
}
$('#image-holder').empty().html('Loading...');
return false;
});