You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
650 B
JavaScript
20 lines
650 B
JavaScript
const playgroundForm = document.getElementById("playground");
|
|
const playgroundSubmit = document.getElementById("playgroundSubmit");
|
|
const playgroundOutput = document.getElementById("playgroundOutput");
|
|
|
|
// console.log(playgroundForm.elements);
|
|
|
|
playgroundSubmit.addEventListener("click", (e) => {
|
|
// sorry for this
|
|
let query = "";
|
|
Object.keys(playgroundForm.dataset).forEach((input) => {
|
|
query += `${input}=${playgroundForm.elements[input].value}&`;
|
|
});
|
|
let endpoint = `${playgroundForm.action}?${query}`;
|
|
fetch(endpoint)
|
|
.then(response => response.text())
|
|
.then((data) => {
|
|
playgroundOutput.innerHTML = data
|
|
});
|
|
});
|