title: jQuery: Load Modal Dialog Contents via Ajax
body: <p>Currently my Modal Dialog is like this</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
    &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/humanity/jquery-ui.css" type="text/css" /&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;div id="dialog" title="Title Box"&gt;
     &lt;p&gt;Stuff here&lt;/p&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript"&gt;
     jQuery(
      function() {
       jQuery("#dialog")
        .dialog(
         {
          bgiframe: true,
          autoOpen: false,
          height: 100,
          modal: true
         }
        );
       jQuery('body')
        .bind(
         'click',
         function(e){
          if(
           jQuery('#dialog').dialog('isOpen')
           &amp;&amp; !jQuery(e.target).is('.ui-dialog, a')
           &amp;&amp; !jQuery(e.target).closest('.ui-dialog').length
          ){
           jQuery('#dialog').dialog('close');
          }
         }
        );
      }
     );
    &lt;/script&gt;
    &lt;a href="#" onclick="jQuery('#dialog').dialog('open'); return false"&gt;Click to view&lt;/a&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The Div that is loaded is included in the same page. How do I move that div to a second page and load the contents via Ajax when the dialog is shown? And can I reuse the script to load different contents as per need?</p>