title: Retrieve element from post data with jquery
body: <p><strong>Note: With the help of some comments it seems like this is most likely not possible</strong></p>
  
  <p>I'm using a jQuery ajax call to send an e-mail address, in the called PHP file I return an error or success message depending on the outcome.</p>
  
  <p>Now I want to alert this outcome after my jQuery <code>$.post</code> is successful, the problem is that the called PHP file includes a config file that also has a Javascript file, so my data will look like this:</p>
  
  <p><code>&lt;script type="text/javascript" src="x.js"&gt;&lt;/script&gt;Message</code></p>
  
  <p>So I tried the following:</p>
  
  <p><strong>Data</strong></p>
  
  <p><code>&lt;script type="text/javascript"&gt; src="x.js"&gt;&lt;/script&gt;&lt;p&gt;Message&lt;/p&gt;</code></p>
  
  <p>And I tried two different things within my <code>$.post</code>:</p>
  
  <p><strong>Post</strong></p>
  
  <pre><code>$.post('ajax.php',function(data){
  
      alert($(data).find('p'));
      // this returns [object Object]
  
      alert($(data).find('p').html());
      // this returns null?
  
  }
  </code></pre>
  
  <p>The fact that <code>alert($(data).find('p'));</code> returns <code>[object Object]</code> leads me to think it is working, but then I don't understand why <code>.html()</code> returns <code>null</code>. If I check <code>data</code> through firebug it shows exactly what I typed above.</p>
  
  <p><strong>Some extra information</strong></p>
  
  <p><code>console.log(data)</code></p>
  
  <p>returns</p>
  
  <p><code>&lt;script type="text/javascript"&gt; src="x.js"&gt;&lt;/script&gt;&lt;p&gt;Message&lt;/p&gt;</code></p>
  
  <hr>
  
  <p><code>console.log($(data).find('p'))</code> returns a jQuery object. </p>
  
  <hr>
  
  <p><code>console.log($(data).find('p').length);</code> returns <code>0</code></p>
  
  <hr>
  
  <pre><code>$('html').append(data);
  console.log($('p').html());` 
  </code></pre>
  
  <p>returns <code>Message</code> as expected.</p>
  
  <p><strong>Final edit</strong></p>
  
  <p>I didn't think about the fact that the <code>$</code> in <code>$(data).find('p')</code> is probably why it's returning <code>[object Object]</code>.</p>
  
  <p>Now that I think about it, it seems quite obvious it's impossible to do what I am asking because I am trying to use jQuery's selector engine on a string. I'll change my document structure to remove the JS reference from my config file instead.</p>