title: jquery synchronous execution
body: <p>I am trying to get the resoution of a remote image. </p>
  
  <pre><code>function getMaxRes(url)
  {
      var imgHeight=0;
       $("&lt;img/&gt;").attr("src", url).load(function(){
           s = {w:this.width, h:this.height};
           imgHeight =  this.height ;   
          console.log(imgHeight); // printed correctly
  
        }); 
       console.log(imgHeight); //prints 0
  
  }
  getMaxRes(&lt; url to the image &gt; )
  </code></pre>
  
  <p>I have tried using global variables. How can I make the function to return the image height.</p>