Getting only a part of a file
<p>I have some very simple sample code like this:</p>

<pre><code>$.ajax({
  url: 'demo2.htm',
  success: function(loadeddata){
    $("#loaded_data").html(loadeddata);
    alert('success');
  },
  error: function(){
    alert('failure');
  }
});
</code></pre>

<p>Loaded data currently returns everything. What I need to is to get only a specific div  and make it the html of #loaded_data.</p>

<p>How do I do that?</p>

<p>Thanks!</p>

<p>Edit:</p>

<p>While trying to use .load()...</p>

<p>Here's what I wrote into the comment. </p>

<p>Thanks, your updated example is great. However I'm not sure what's wrong with mine.</p>

<p>This: works</p>

<pre><code>$("#loaded_data").load("demo2.htm #mydiv", function(text, status, request) {
    if(status == 'success') {
        alert('success');
    } else {
        alert('error');
    }
});
</code></pre>

<p>This: </p>

<pre><code>$("#loaded_data").load("demo5.htm #mydiv", function(text, status, request) {
    if(status == 'success') {
        alert('success');
    } else {
        alert('error');
    }
});
</code></pre>

<p>Does not. It just hangs. There is no demo5.htm But no error is returned.</p>

<p>Thanks a lot again for all of your help.</p>
