My Knockoutjs code goes as following:
function chainModel(){
var self = this;
this.total_count = ko.observable();
function get_total_count(number){
$.ajax({
type : "get",
url : "./XYZ/abc.php",
cache : false,
data : {number: number},
success : function(result){
self.total_count($.parseJSON(result));
},
error : function(jqXHR, textStatus, errorThrown){
console.log("Error ! Unable to get step " + $number + " count." + "Error: " + errorThrown + ", Status: " + textStatus);
}
});
}
}
ko.applyBindings(new chainModel());
Inside the get_total_count() function, I am assigning the ajax result to self.total_count observable. Instead, I would like to pass the observable too as an parameter to the get_total_count() function so that I can reuse the same function for more than one observable.