title: QML ListModel unable to update
body: <p><br/>
  I've just started working on QML and it looks promising because I really like C. While experimenting, I came to a point where I had to update a ListModel from a PHP service using an Ajax request. I referred to <a href="http://www.makina-corpus.org/blog/access-json-webservice-qt-c" rel="nofollow">this</a> link, but I can't seem to make it work. My code follows.</p>
  
  <p>try.js:</p>
  
  <pre><code>function load() {
      listModel.clear();
      var xhr = new XMLHttpRequest();
      xhr.open("GET", "http://&lt;url&gt;/service_newsletter.php?method=news", true);
      xhr.onreadystatechange = function() {
          if(xhr.readyState == xhr.DONE){
              if(xhr.status == 200) {
                  var jsonData = JSON.parse(xhr.responseText);
                  for(var index in jsonData.data.posts) {
                      listModel.append({
                          "text": jsonData.data.posts[index].text,
                          "description": jsonData.data.posts[index].description});
                      alert(jsonData.data.posts[index].text);
                  }
              }
          }
      }
      xhr.send();
  }
  </code></pre>
  
  <p>QML Code:</p>
  
  <pre><code>import QtQuick 1.1
  import "try.js" as JS
  
  Item {
      id:root
      width: 360
      height: 640
  
      Component.onCompleted: JS.load()
  
      ListModel {
          id:listModel
      }
  
      ListView {
          id:view
          anchors.fill:parent
          model : listModel
          delegate: Rectangle {
               width:parent.width
               height:80
               Text {
                  anchors.centerIn:parent
                  text: text
               }
          }
      }
  }
  </code></pre>
  
  <p><strong>NOTE:</strong> using Necessitas to deploy Qt apps on Android!</p>
  
  <p><strong>NOTE 2:</strong> the format of the JSON data from my server is similar to the one given in the example link above.</p>