I have a checkbox and click event for checkbox for updating data. When I click on the checkbox the data is updating but the checkbox does not get not checked.
This is my html code:
<td>
<input type="checkbox" data-bind="checked: status, disable: status, click: $root.UpdateStatus" />
</td>
This is my script:
self.UpdateStatus = function (tblUsers) {
$.ajax({
type: "POST",
url: 'SinglePageApp.aspx/UpdateStatus',
data: "{statusVal: 'true',goalId: " + tblUsers.goalId + "}",
contentType: "application/json; charset=utf-8",
success: function (result) {
alert(result.d);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
}
});
};
I want my checkbox to get checked when it is clicked. And after that put updated data after checkbox clicked.
See: http://knockoutjs.com/documentation/click-binding.html
Edit: added example showing where to return
truein the function. It has to be return from the actual function itself, not the Ajaxsuccessorerrorhandler.