title: How to refresh a DIV in jquery (mobile)?
body: <p>UPDATE: Sorry, I accidentally copied the <code>data-dom-cache="true"</code> line into my content-div. Seems very logical that the app is loading from the dom instead the new content! I've changed it to <code>false</code> and now it works perfectly.</p>
  
  <h2>Thanks.</h2>
  
  <p>I have a list which is dynamically generated. If someone is clicking on an entry in the list, the user is redirected to a new page where the data is loaded (dynamically). The data which is loaded depends on the list entry which the user has clicked.</p>
  
  <p>When the app is loaded the first time, all things work well. But when the user is clicking on another list entry, the same data are represented as on the first run.</p>
  
  <p>I've played around with the <code>.empty()</code> function from jQuery (to clear the div and append the new data) but it doesn't work.</p>
  
  <p>EDIT:</p>
  
  <p>My headlines.html file looks like this:</p>
  
  <pre><code>&lt;div id="content&gt;
    &lt;div id="headlineslist"&gt;
      &lt;ul data-role="listview" data-theme="c" id="headlineslist"&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;script&gt;
    $(document).ready(function() {
      HeadlinesLoad();
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>Here's the Javascript file:</p>
  
  <pre><code>function HeadlinesLoad() {
    $.ajax({
      type: "POST",
      url: "headlines_getter.php",
      dataType: 'json',
      cache: false,
      success: function(data1) {
        $.each(data1, function(i, currentObj) {
          $('ul#headlineslist').append('&lt;li data-role="list-divider" 
  class=​"ui-li ui-li-divider ui-bar-b"&gt;​' + currentObj.main + '&lt;/li&gt;​').listview('refresh');
          $.each(currentObj.sub, function (j, currentSub) {
            $('ul#headlineslist').append('&lt;li&gt;
  &lt;a href="headlinesclicked_temp.html" onclick="headlineID(' + currentSub.sid + ')"&gt;' + currentSub.name + '&lt;/a&gt;&lt;/li&gt;').listview('refresh');
          });
        });
      }
    });
  }
  
  function headlineID(hID) {
    window.localStorage.setItem("headlineID", hID);
  }
  
  function onHeadlinesLoad() {
    var hID = window.localStorage.getItem("headlineID");
    window.localStorage.removeItem("headlineID");
    window.localStorage.clear();
    $.ajax({
      url: "headlinesclicked_getter.php?hID=" + hID,
      success: function(html) {
        if(html){
          $("#headlineshome").empty();
          $("#headlineshome").html(html);
        }
      }
    });
  }
  </code></pre>
  
  <p>And here is the snippet which lays in the HTML file where the data should be displayed (and refreshed on every new click the user does):</p>
  
  <pre><code>&lt;div data-role="content" id="headlineshome"&gt;&lt;/div&gt;
  &lt;script&gt;
    $(document).ready(function() {
      onHeadlinesLoad();
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>I don't know why it doesn't work, so I ask you for help.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Best regards, John.</p>