The below AJAX calls work (notice the first one calls the second one on success), however on success of the second call it reloads the browser, and the changes are not always displayed immediately without the user having to manually reload the page a second time. Any way to fix this behavior?
self.assign = function () {
var data = {
selectedViewsForClient: self.selectedViewsForClient().toString(),
volPoolIds: populateSelectedVolPoolIds().toString()
};
var jsonData = ko.toJSON(data);
$.ajax({
url: "../../act/ClientView/assign",
type: "POST",
contentType: "application/json; charset=utf-8",
cache: false,
data: jsonData,
success: self.removeViews,
error: handleEditViewsErrors
});
};
self.remove = function () {
var data = {
selectedViewsForClient: self.selectedViewsAssignedToCandidateForClientUser().toString(),
volPoolIds: populateSelectedVolPoolIds().toString()
};
var jsonData = ko.toJSON(data);
$.ajax({
url: "../../act/ClientView/remove",
type: "POST",
contentType: "application/json; charset=utf-8",
cache: false,
data: jsonData,
success: location.reload(),
error: handleEditViewsErrors
});
};