how to submit data using knockout..
and i have below form like this..
Employee Id: | |
Name: | |
Designation: | |
Department Name: | |
  | |
$('#btnSave').live("click", function (e) {
var viewModel = {
this.EmpId: ko.observable(""),
this.EmpName: ko.observable(""),
this.Designation: ko.observable(""),
this.deptid:ko.observable("")
};
ko.applyBindings(viewmodel);
$.ajax({
url: '/Home/Save/',
async: true,
cache: false,
type: 'post',
data: ko.toJSON(viewmodel),
contentType: 'application/json',
success: function (result) {
$("lblResult").val("Recorded inserted Sucessfully");
$("txtempid").text("");
$("txtdeptid").text("");
$("txtempname").text("");
$("txtdesignation").text("");
}
});
});
Replies
Know the answer? Post it — somebody with the same question will find it here.