title: shadowbox display of html drawn from another page via jQuery.get()
body: <p>I'm a bit new to the Ajax thing and am hoping you all can suggest which of these two methods is most efficient. Both approaches seem to work, but perhaps there is some better way altogether? </p>
  
  <p>thisPage.html wants to display a blob of html drawn from thatPage.html (on the same host) in response to a click on a link. I'm using Shadowbox's html player to display the blob, and I'm using jQuery's get() as a shortcut to the XMLHttpRequest.</p>
  
  <p>In my first solution, thisPage.js contains this function:</p>
  
  <pre><code>function loadEntry(entry){
    jQuery.get('thatPage.html', function(data){
      var elem = document.createElement("div");
      elem.innerHTML = "&lt;div class='entry-to-show'&gt;" + jQuery(data).find("a[name='" + entry + "']").parent().parent().html() + "&lt;/div&gt;";
  
      Shadowbox.open({
        options: {
          enableKeys: false
        },
        player: 'html',
        content: elem.innerHTML
      });
    });
  };
  </code></pre>
  
  <p>But then I thought, rather than have thisPage load thatPage every time loadEntry is called, I'd just call it once when thisPage.js is loaded, wrap it up as a variable containing a jQuery object and access it like this:</p>
  
  <pre><code>var $Content = null;
  
  jQuery.get('thatPage.html', function(data){
    $Content = jQuery(data).find("#content");
  });
  
  function loadEntry(entry){
  
    elem = $Content.find("a[name='" + entry + "']").parent().parent().html();
  
    Shadowbox.open({
      options: {
        enableKeys: false
      },
      player: 'html',
      content: elem
    });
  };
  </code></pre>
  
  <p>Is this second method actually more efficient, or is there some other approach that would be more appropriate for what I'm trying to do? Any advice or general observations would be welcome.</p>
  
  <p>Thanks,
  jjon</p>