let databox;
function initiate() {
  databox = document.getElementById("databox");

  const button = document.getElementById("button");
  button.addEventListener("click", senddata);
}
async function senddata() {
  const data = new FormData();
  data.append("name", "John");
  data.append("lastname", "Doe");

  const url = "process.php";
  try {
    const response = await fetch(url, {
      method: "POST",
      body: data
    });
    if (response.ok) {
      const text = await response.text();
      databox.innerHTML = text;
    }
  } catch (error) {
    console.log(error);
  }
}
window.addEventListener("DOMContentLoaded", initiate);