function SaveAccess() { var access = new Object(); access.RoleId = $("#accessid").val(); access.Role = $("#role").val(); access.Tag = $("#tag").val(); access.Status = $("#status").val(); var data = JSON.stringify({ access: access }); swal("Access!", "Access is successfully granted", "success"); $("#success-message").click(function (e) { Swal.fire({ title: "Good job!", text: "You clicked the button!", icon: "success", buttonsStyling: false, confirmButtonText: "Confirm me!", customClass: { confirmButton: "btn btn-primary" } }); }); return $.ajax({ contentType: 'application/json; charset=utf-8', dataType: 'json', type: 'POST', url: "/Home/SaveAccess", data: data, success: function (result) { if (result.result) { $("#AccessModal").modal('hide'); Reset(); dataTable.ajax.reload(); } else { swal("Access Fail!") } }, error: function () { swal("Error") } }); }