title: Load HTML/Javascript dynamically
body: <p>I have an index.html page and I want to load the content of another page to index.html dynamically using jQuery. I use $.load() function to do this :</p>
  
  <pre><code>$('#dynamic_content').load('another.html #toLoad')
  </code></pre>
  
  <p>It works fine, but I need also to load javascript files that uses another.html, so I do:</p>
  
  <pre><code>$('#dynamic_content').load('another.html #toLoad');
  $.getScript('js/another.js');
  </code></pre>
  
  <p>The problem is that the js code of 'another.js' sometimes doesn't 'apply' to html page(maybe it loads earlier than the html page) 
  Content of another.js: </p>
  
  <pre><code>$(document).ready(function {} {
  
     $('#cancelButton').click(function() {
         //do something 
  
  });
  
  });
  </code></pre>