title: ajax call occurs after ko binding is applied
body: <p>I am trying to pull data from a database using an ajax call and then put that data in a view model which will then be bound to a table using knockout.  Here is my code: </p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          var LoadFiles = '@Url.Action("Files", "Home")';
  
          var HomeModel = function () {
              debugger
              var self = this;
              self.rows = ko.observableArray([]);
  
              $.ajax({
                  method: "POST",
                  url: LoadFiles,
                  success: function (data) {
                      alert('inside ajax call');
                      self.rows = JSON.parse(data);
                  },
                  error: function (data) {
                      alert('error');
  
                  }
              });
          }
  
              alert('outside ajax call');
              var model = new HomeModel();
              debugger
              ko.applyBindings(model);
      });  
  &lt;/script&gt;    
  &lt;pre data-bind="text: ko.toJSON($data, null, 2)"&gt;&lt;/pre&gt;
  </code></pre>
  
  <p>However, the problem is that my view model.rows is empty because as I discovered through some alert("") calls, the  `alert('outside ajax call'); is called first, then the page loads and binding is applied, then the  alert('inside ajax call'); is called.  I don't understand how this is possible especially since I call var model = new HomeModel() before the bindings are applied.  How can I ensure that the self.rows of my HomeModel are populated before the page loads to ensure my .rows are not empty? </p>
  
  <p>UPDATE:
  Thanks to @RoyJ, this now works as expected: </p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          var LoadFiles = '@Url.Action("Files", "Home")';
  
          var HomeModel = function () {
              debugger
              alert('above');
              var self = this;
              self.rows = ko.observableArray([]); 
  
              $.ajax({
                  method: "POST",
                  url: LoadFiles,
                  success: function (data) {
  
                      alert('inside ajax call');
                      self.rows(JSON.parse(data))
                      alert('below');
                  },
                  error: function (data) {
                      alert('error');
  
                  }
              });
          }
  
              alert('outside ajax call');
              var model = new HomeModel();
              debugger
              ko.applyBindings(model);
      });
  
  
  &lt;/script&gt;
  
  &lt;pre data-bind="text: ko.toJSON($data, null, 2)"&gt;&lt;/pre&gt;
  </code></pre>