title: Access jQuery data from iframe element
body: <p>Lets say I have a page on the <strong>same domain</strong> that I put inside an iframe. In the iframe, I have added data to an element, something like this:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div id="data"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Script</p>
  
  <pre><code>$('#data')
      .data('test1', 'this is test data 1')
      .data('test2', ['John', 'Smith'])
      .data('test3', {
          alert1: function() {
              $('#data').append('test3: successful&lt;br&gt;');
          }
      })
  </code></pre>
  
  <p>Now once this page is in an iframe, I know I can access the element as follows:</p>
  
  <pre><code>$('#frame').contents().find('#data');
  </code></pre>
  
  <p>But when I try to get the data from that element, it's always undefined.</p>
  
  <pre><code>$('#frame').contents().find('#data').data('test1'); // shows up as undefined
  </code></pre>
  
  <p>I know jQuery stores <code>data()</code> internally in a <code>cache</code> object, but I don't know how to access it from outside that document. I set up <a href="http://jsfiddle.net/Mottie/c5JeU/1/" rel="nofollow noreferrer">this demo</a> to display my problem. Click the "Get Frame Data" button to see the results. </p>
  
  <p>I would appreciate any input :)</p>