Yes. My website mainly uses images, so I Reference lazyload. js and infinitescroll. js is good for user experience, infinitescroll. javascript uses ajax to automatically load the content of the next page when the page is rolled down. The problem is that the image of the next page loaded by ajax l... yes. My website mainly uses images, so I Reference lazyload. js and infinitescroll. js is good for user experience, infinitescroll. javascript uses ajax to automatically load the content of the next page when the page is rolled down.
The problem is that the lazyload. js image on the next page loaded by ajax is invalid, the image cannot be displayed, and some JavaScript files cannot work.
I have been using Baidu for a long time and want to bind events, such as sliding display or clicking display:
$('body').on('mouseover' , '.myDrop' , function() { $(this).addClass('open'); } );
This binding works, but the lazyload. js configuration is executed when the page is loaded. What should I do?
The following is the configuration of lazyload. js:
$(function() { $("img.img-responsive").lazyload({ effect : "fadeIn", threshold : 200 }); });Reply content:
1. If you have to do so, initialize lazyload again during ajax callback.
2. You can re-execute your initialization code after each ajax operation, so that you can
$.ajax({ type: "POST", url: "XXX", data: "XXXX", success: function(msg){ $("img.img-responsive").lazyload({ effect : "fadeIn", threshold : 200 }); }});
After ajax is used, lazyload. js becomes invalid. How can this problem be solved? For more information, see the PHP Chinese website (www.php1.cn )!