title: How I do initial JavaScript Ajax initialization?
body: <p>I'm pulling information with ajax. I want it my document.ready function(ajax) starting first because knockout file starting first and my "var initialData" value going null. How my Ajax start first ?</p>
  
  <p><a href="https://i.stack.imgur.com/2BHFS.png" rel="nofollow noreferrer">Here is my F12 Source</a></p>
  
  <p>My script:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          var initialData;
          function functionViewModel() {
                  $(document).ready(function () {
                      $.ajax({
                          type: "POST",
                          url: "KnockoutGrid2.aspx/GonderUrunler",
                          data: "{}",
                          contentType: "application/json; charset=utf-8",
                          dataType: "json",
                          success: function (msg) {
                              console.log(msg.d);
                              initialData = msg.d;
                          }
                      });
                  });
              var fn = {
                  friends: ko.observableArray(initialData)
              };
              fn.removeUser = function (item) {
                  fn.friends.remove(item);
              };
              return fn;
          };
          ko.applyBindings(functionViewModel());
      &lt;/script&gt;
  </code></pre>