You need to do something like this ->
// Add an event listener to the edit form's submit event
editForm.addEventListener("submit", async function (event) {
// Prevent the default form submit behavior
event.preventDefault();
// Create a FormData object from the edit form
const formData = new FormData(editForm);
//console.log("form data", formData);
// Send a POST request to the edit_update_blog.php endpoint with the form data
const response = await fetch("edit_update_blog.php", {
method: "POST",
body: formData,
});
// Check if the request was successful
if (response.ok) {
const result = await response.json();
console.log(result);
// If the response has a "success" property and its value is true, clear the form
if (result.success) {
resultInput.value = ''; // Clear the current value of the search input field
resultInput.placeholder = "New Search"; // Set the placeholder to `New Search`
image_for_edit_record.src = "";
image_for_edit_record.alt = "";
editForm.reset(); // Resetting the edit form
searchForm.reset(); // Resetting the search form
// Reset select box to default (first) option
const selectBox = document.querySelector('select[name="heading"]');
selectBox.selectedIndex = 0;
}
} else {
console.error(
"Error submitting the form:",
response.status,
response.statusText
);
// Handle error response
}
});
also using `console.log` helps in debugging, plus your `sql_connection.php` is expecting back json data back.