I'm trying to fetch data from database and show it
here is my knockoutjs code
/// <reference path="jquery-2.1.1.js" />
/// <reference path="knockout-3.1.0.js" />
var viewModel= {
realEstates:ko.observableArray([]),
}
$(document).ready(function() {
$.ajax({
url: "index.aspx",
contentType: "text/json",
type: "GET",
success: function(data) {
$.each(data,function(index) {
viewModel.realEstates.push(toKnockOutObservable(data[index]));
});
ko.applyBindings(viewModel);
},
error: function(data) {
alert("error occured");
}
});
// function used in success just to return the value
function toKnockOutObservable(realEstate) {
return {
ID: ko.observable(realEstate.ID),
City: ...
Go to the complete details ...