Make reset postcode button work

This commit is contained in:
Remo Zaros
2026-05-14 13:53:23 +02:00
parent 2f430be382
commit 4bd6de0916
3 changed files with 56 additions and 11 deletions

View File

@@ -1,14 +1,32 @@
document.addEventListener("click", function (event) {
event.preventDefault();
if (event.target.matches(".reset-postcode-show-comfirm")) {
console.log("link1 button clicked!");
event.preventDefault();
document.querySelector(".bevestiging").dataset.open = true;
}
if (event.target.matches(".accept")) {
event.preventDefault();
console.log("link2 button clicked!");
fetch(ajax_object.ajax_url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({
action: "unset_my_session",
nonce: ajax_object.nonce, // The nonce value
}),
})
.then((response) => response.json())
.then((data) => {
if (data.success) {
window.location.reload();
}
});
}
if (event.target.matches(".decline")) {
console.log("link3 button clicked!");
event.preventDefault();
document.querySelector(".bevestiging").dataset.open = false;
}
});