Beginner trying to redirect users to an HTML page instead of Appscript JSON result
See original GitHub issueHello Author,
I am a beginner and i didn’t understand the note saying :
" If you want to intercept the submit event so the user isn’t redirected to the webapp, you can do this by attaching a JavaScript event listener to the form submission and creating the POST request yourself "
I dont want the user to have an “https://script.googleusercontent.com/macros/echo?user_content_key=....etc”
and a JSON response like this :
The JS in codepen is the following. I don’t really understand were to put it. Can you help me please ?
Before all i have to say that i was more a lowcoder (with appsheet and Excel VBA)
Thank you by advance
window.addEventListener("load", function() { const form = document.getElementById('my-form'); form.addEventListener("submit", function(e) { e.preventDefault(); const data = new FormData(form); const action = e.target.action; fetch(action, { method: 'POST', body: data, }) .then(() => { alert("Success!"); }) }); });
(i created a Github account just because of this. A great opportunity 😃 )
El Moumen Y.
Issue Analytics
- State:
- Created a year ago
- Comments:11
Top GitHub Comments
Detail please
@elmoumenyassine First, assign an id to your form (
<form id="yourFormID" ...
) Next, addto your js source or HTML source (inside
script
tag)