I have a code like this. There are two conditions for the content to load. Successful response and if image loaded (function waitFormages). How do I make a condition by type if 500ms has passed load? Without using setTimeout. setTimeout will simply delay the load. ie each time will pass 500 ms and then load.
/* ---- */
// item
$('.js_toggle-item').click(function() {
var url = $(this).attr('data-item-url');
// ajax load
$('.js_control-item').load('/i/' + url + ' #item_component', function (response, status, xhr) {
if (status == 'success') {
$('.it').waitForImages(function() {
$('.js_page-backdrop').removeAttr('style');
$('.js_control').attr('data-state', 'item');
$('.js_control').attr('style', 'transform: translate3d(0, calc(80px), 0)');
});
}
});
});
/* ---- END */