Hello world!





document.getElementById(“dataForm”).onsubmit = async function(event) {
event.preventDefault();

const formData = {
name: document.getElementById(“name”).value,
email: document.getElementById(“email”).value,
message: document.getElementById(“message”).value
};

const response = await fetch(“/generate-word”, {
method: “POST”,
headers: {
“Content-Type”: “application/json”
},
body: JSON.stringify(formData)
});

if(response.ok) {
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement(“a”);
a.href = url;
a.download = “generated_document.docx”;
document.body.appendChild(a);
a.click();
a.remove();
}
};


Comentários

Uma resposta para “Hello world!”

  1. Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

Deixe um comentário para A WordPress Commenter Cancelar resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *