-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
26 lines (23 loc) · 962 Bytes
/
scripts.js
File metadata and controls
26 lines (23 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
document.getElementById('ideaForm').addEventListener('submit', async function(event) {
event.preventDefault();
const idea = document.getElementById('ideaInput').value;
const email = document.getElementById('emailInput').value;
const responseContainer = document.getElementById('responseContainer');
responseContainer.innerHTML = 'Generating and sending PDF...';
try {
const response = await fetch('/send-pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ idea, email })
});
if (response.ok) {
responseContainer.innerHTML = 'PDF sent to your email successfully!';
} else {
responseContainer.innerHTML = 'An error occurred while sending the PDF.';
}
} catch (error) {
responseContainer.innerHTML = 'An error occurred while sending the PDF.';
}
});