Wednesday, 15 February 2012

javascript - when is triggered AJAX success? -



javascript - when is triggered AJAX success? -

i want load html document ajax, want show when images in document loded.

$('.about').click(function () { $(".back").load('tour.html', function () { $(".back").show(); }); });

".back" should visible when images in tour.html loaded, when triggered success event??

$(".back").load('tour.html', function (html) { var $imgs = $(html).find('img'); var len = $imgs.length, loaded = 0; $imgs.one('load', function() { loaded++; if (loaded == len) { $(".back").show(); } }) .each(function () { if (this.complete) { $(this).trigger('load'); }); });

this requires @ to the lowest degree 1 <img> in returned html.

javascript jquery ajax

No comments:

Post a Comment