function submitCreateCaseForm($formStatus) {
Swal.fire({
title: "Do you want to save the changes?",
showDenyButton: true,
showCancelButton: true,
confirmButtonText: "Save",
denyButtonText: `Don't save`,
}).then((result) => {
if (result.isConfirmed) {
$("#form_status").val($formStatus);
$.ajax({
type: "POST",
url: rootURL + "api/v1/case/add",
data: $("#msform").serialize(),
success: function (response) {
if (
response === "Case successfully created and submitted"
) {
Swal.fire({
icon: "success",
title: "Saved!",
html: `<center>Case successfully created and submitted.</center>`,
});
$("#error-form").empty();
location.assign(
rootURL + "admin/case-folder/master-list"
);
} else if (
response === "Case successfully saved as draft"
) {
Swal.fire({
icon: "success",
title: "Saved!",
html: `<center>Case successfully saved as draft.</center>`,
});
$("#error-form").empty();
location.assign(
rootURL + "admin/case-folder/master-list"
);
} else if (
response ===
`Sorry you don't have the rights to create case please contact the administrator`
) {
Swal.fire({
icon: "error",
title: "Error!",
html: `<center>Sorry you don't have the rights to create case please contact the administrator.</center>`,
});
$("#error-form").empty();
location.assign(
rootURL + "admin/case-folder/master-list"
);
} else {
Swal.fire("The case was not created!", "", "error");
html = "";
$.each(response, function (index, value) {
html +=
'<p class="d-flex justify-content-center text-danger">' +
value +
"</p>";
});
html += "<hr>";
$("#error-form").empty().prepend(html);
}
},
});
} else if (result.isDenied) {
Swal.fire("Changes are not saved", "", "info");
}
});
}
I want to save data to my localhost but it's not saving and always looking for url: rootURL + "api/v1/case/add",