1
0

A one minute googling gave me a resolve to my question why Firefox was failing with a NetworkError. That's because I forgot about preventDefault()!

This commit is contained in:
Alexander Andreev 2023-05-23 03:41:02 +04:00
parent 45c2ff6505
commit db41e25c84
Signed by: Arav
GPG Key ID: D22A817D95815393
2 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,7 @@ function get_field(e, el) {
// EDIT ENTRY
function edit_entry(e) {
e.preventDefault();
let data = new URLSearchParams();
data.append("message", get_field(e.target, "message"));
data.append("name", get_field(e.target, "name"));
@ -21,6 +22,7 @@ for (const edit_entry_button of document.getElementsByName("edit-entry"))
// DELETE ENTRY
function delete_entry(e) {
e.preventDefault();
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}`, {method:"DELETE"})
.catch(e => console.log(e))
.then(() => window.location = "/guestbook/admin");
@ -32,6 +34,7 @@ for (const delete_entry_button of document.getElementsByName("delete-entry"))
// EDIT REPLY
function edit_reply(e) {
e.preventDefault();
let data = new URLSearchParams();
data.append("message", get_field(e.target, "message"));
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method: "PATCH", body: data})
@ -45,6 +48,7 @@ for (const edit_reply_button of document.getElementsByName("edit-reply"))
// DELETE REPLY
function delete_reply(e) {
e.preventDefault();
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method:"DELETE"})
.catch(e => console.log(e))
.then(() => window.location = "/guestbook/admin");
@ -56,6 +60,7 @@ for (const delete_reply_button of document.getElementsByName("delete-reply"))
// NEW REPLY
function send_reply(e) {
e.preventDefault();
let data = new URLSearchParams();
data.append("message", get_field(e.target, "message"));
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method: "POST", body: data})

View File

@ -3,6 +3,7 @@ function get_field(e, el) {
}
function edit_post(e) {
e.preventDefault();
let data = new URLSearchParams();
data.append("category", get_field(e.target, "category"))
data.append("new-category", get_field(e.target, "new-category"))
@ -18,6 +19,7 @@ for (const edit_post_button of document.getElementsByName("edit-post"))
edit_post_button.addEventListener("click", edit_post);
function delete_post(e) {
e.preventDefault();
fetch(`/api/mindflow/${get_field(e.target, "post-id")}`, {method:"DELETE"})
.catch(e => console.log(e))
.then(() => window.location = "/mindflow/admin");
@ -27,6 +29,7 @@ for (const delete_post_button of document.getElementsByName("delete-post"))
delete_post_button.addEventListener("click", delete_post);
document.getElementById("manage-categories").elements["add"].addEventListener("click", ev => {
ev.preventDefault();
let data = new URLSearchParams();
data.append("name", get_field(ev.target, "name"));
fetch(`/api/mindflow-category`, {method: "POST", body: data})
@ -35,6 +38,7 @@ document.getElementById("manage-categories").elements["add"].addEventListener("c
});
document.getElementById("manage-categories").elements["edit"].addEventListener("click", ev => {
ev.preventDefault();
let data = new URLSearchParams();
data.append("name", get_field(ev.target, "name"));
fetch(`/api/mindflow-category/${get_field(ev.target, "category")}`, {method: "PATCH", body: data})
@ -43,6 +47,7 @@ document.getElementById("manage-categories").elements["edit"].addEventListener("
});
document.getElementById("manage-categories").elements["delete"].addEventListener("click", ev => {
ev.preventDefault();
fetch(`/api/mindflow-category/${get_field(ev.target, "category")}`, {method: "DELETE"})
.catch(e => console.log(e))
.then(() => window.location = "/mindflow/admin");