jquery.lazy icon indicating copy to clipboard operation
jquery.lazy copied to clipboard

Custom loader using Ajax fails (not even fired), while lazyloading images work.

Open SuN-80 opened this issue 1 year ago • 1 comments

Hi, I use this plugin to lazyload images and scripts, and it works well. But for some reason, it doesn't when I create a custom ajax loader.

This is my code:

$(function() {
	$('img.lazy').lazy({ effect: "fadeIn", effectTime: 1000 }); // works

	$('span.status').lazy({ // this does not works
		threshold: 0,
		checkstatus: function(el, response)  {
			$.ajax({
				url: '/ajax/check',
				method: 'POST',
				dataType: 'json',
				data: { id: $(el).data('id') },
				success: function(data) {
					if(data.valid== true)
						el.append(data.label).addClass('valid').hide().fadeIn('fast');
						
					response(true);
				},
				error: function() {
					console.log("oops.");
					response(false);
				}
			});
		}
   });
});

And here is the html:

<a href="/link">
        <span class="status" data-id="17" data-loader="checkstatus"></span>
         <img class="lazy" src="/img_load.png" data-src="/img/img.jpg" >
</a>

Any idea what's going wrong? Thanks.

SuN-80 avatar Jul 26 '23 12:07 SuN-80

Hi. What exactly is the problem? Are there any errors? What have you debugged so far? Some more details would be good.

dkern avatar Sep 07 '23 13:09 dkern