firstPHP/public/js/ajax.js
2024-04-16 17:13:42 +03:00

12 lines
359 B
JavaScript

function ajaxRequest() {
const request = new XMLHttpRequest();
request.open("POST", "handler");
request.addEventListener("load", () => {
const responseText = request.responseText;
const targetElement = document.getElementById("buttonAdd");
targetElement.insertAdjacentHTML("beforebegin", responseText);
});
request.send();
}