Knockout JS binnding the ajax result
<p>I am new to Knockout JS, I am trying to bind the ajax result data to Knockout JS viewmodel, but I am facing the problem while binding the data to view, I have create model and viewmodel and I am getting the result from ajax. Need help.</p>

<p>Below is my code:</p>

<pre><code>// ajax on page load///
$.ajax({
    type: "POST",
    dataType: "json",
    url: baseUrl + 'api/xxx/xxx',
    data: UserProfileModel,
    success: function(data) {
        result = data;
        ////view model////
        userDetailsViewModel(result);
    },
    error: function(error) {
        jsonValue = jQuery.parseJSON(error.responseText);
        //jError('An error has occurred while saving the new part source: ' + jsonValue, { TimeShown: 3000 });
    }
});

//// view model///
var userDetailsViewModel = function(result) {
    console.log(result);
    self = this;
    self.user = ko.observable(new userModel(result));
};

$(document).ready(function() {
    ko.applyBindings(userDetailsViewModel());
});

/// Model////
function userModel(result) {
    this.name = ko.observable();
    this.userName = ko.observable();
}
</code></pre>