title: Knockout JS to update view model from ajax success that can be call outside of scope
body: <p>Here I have define self.fromDate = ko.observable() and self.toDate = ko.observable() now this value is set when click event of button in function is call with ajax request. On success ajax call need to set values to these two view model. And set value must be accessible outside of ajax success function as well </p>
  
  <pre><code>var app = function(){
     self.fromDate = ko.observable();
     self.toDate = ko.observable();
     self.setThisYear = function(){
        $.getJSON("/Dashboard/GetFiscalYearDetails", function (data) {
              self.fromDate(data.fromDate);
              self.toDate(data.toDate);
              console.log(self.fromDate()); //set data
              console.log(self.toDate());   //set date
        }
        console.log(self.fromDate()); //undefined
        console.log(self.toDate());   //undefined
     }
  }
  ko.applyBindings(new app());
  
  &lt;a href="#" data-bind="click: setThisYear"&gt;This Year&lt;/a&gt;
  </code></pre>