title: jQuery AJAX - Creating DOM elements
body: <p>I am having this function in jQuery where I'm getting new posts with AJAX and PHP. And then creating a new div and appending the post to it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>function getMorePosts(latestPost){
  
      $.ajax({
          type: "POST",
          url: "/includes/classes/handler.php?do=getMorePosts",
          data: "&amp;latestPost="+latestPost,
          cache: false,
          success: function(data){
              if(data){
                  $('#addUpdate textarea').val('');
                  $('&lt;div id="newPosts"&gt;&lt;/div&gt;').insertAfter('.myDeskAdd');
                  $(data).prependTo('#newPosts');
              }
          }
      });
      return false;
  }
  </code></pre>
  
  <p>Now, data is all of HTML code from my handler.php. Everything works, it's appending and I can see the result on the screen. And it's correct - nice! </p>
  
  <p>But here is my problem: 
  When it's added to the screen, it's like I cant 'use' the DOM elements. For example: I have an image which I can click, and then it has to call an alert from jQuery, but it's not. And all other jQuery effects bound to the dom elements created doesn't work.</p>
  
  <p>Those elements not working DOES work if I press F5. </p>
  
  <p>I have tried <code>html()</code>, <code>prepend()</code>, <code>append()</code> and so on.</p>