Files
wp-postcode-plugin/assets/reset-postcode.js
2026-05-14 13:53:23 +02:00

33 lines
906 B
JavaScript

document.addEventListener("click", function (event) {
if (event.target.matches(".reset-postcode-show-comfirm")) {
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")) {
event.preventDefault();
document.querySelector(".bevestiging").dataset.open = false;
}
});