Wait for image to be loaded after AJAX response - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Wait for image to be loaded after AJAX response

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from   w w  w. java2  s  .co  m*/
var newPicture = 'http://www.java2s.com/style/download.png';
$("#newPic").attr("src", newPicture).load(openCrop);
function openCrop() {
    console.log('openCrop called');
}
    });

      </script> 
 </head> 
 <body> 
  <img id="newPic" src="http://www.java2s.com/style/demo/InternetExplorer.png">  
 </body>
</html>

Related Tutorials