dfmmalaw
5/15/2017 - 4:44 PM

Make two AJAX "POST" requests where first one calls second on success and seconds reloads page on success.

Make two AJAX "POST" requests where first one calls second on success and seconds reloads page on success.

self.saveViews = function () {
            $("#sortLoading").modal("show");

            var data = {
                selectedViewsForClient: self.selectedViewsForClient().toString(),
                volPoolIds: populateSelectedVolPoolIds().toString()
            };

            var jsonData = ko.toJSON(data);

            $.ajax({
                url: "../../japi-act/ClientView/assignViews",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                cache: false,
                data: jsonData,
                success: self.removeViews,
                error: handleEditViewsErrors
            });                        
        };

        self.removeViews = function () {

            var data = {
                selectedViewsForClient: self.selectedViewsAssignedToCandidateForClientUser().toString(),
                volPoolIds: populateSelectedVolPoolIds().toString()
            };

            var jsonData = ko.toJSON(data);

            $.ajax({
                url: "../../japi-act/ClientView/removeViews",
                type: "POST",
                async: false,
                contentType: "application/json; charset=utf-8",
                cache: false,
                data: jsonData,
                success: location.reload(),
                error: handleEditViewsErrors
            });
        };