Wait For Ajax Result To Bind Knockout Model
I have getGeneral function that calls ajax GET. When ajax recieves data (json), it creates KO model from given json and returns created KO. When Knockout model is created and value
Solution 1:
Try using the returned promise interface:
function getGeneral(pid) {
return $.ajax({
url: "/api/general",
contentType: "text/json",
dataType: "json",
type: "GET",
data: {
id: pid
}
});
}
getGeneral("@Model.Id").done(function (item) {
var p = new GeneralModel();
p = ko.mapping.fromJS(item);
ko.applyBindings(p, document.getElementById("pv-portfolio-general-tab"));
}).fail(function () {
//handle error here
});
Post a Comment for "Wait For Ajax Result To Bind Knockout Model"