I have a html page. It has a number of forms.
I want a generic function that, after any form is submitted, will take all of the input of that form and send it as JSON to another server.
From what I understand, what I want is the following:
<form enctype="application/json" name="createStudentForm" onsubmit="sendForm()"> Student ID (must be 3 digit number): <input type="text" name="student_id"><br> Nickname: <input type="text" name="student_nickname"><br> <input type="submit"> </form> And later:
<script> function sendForm(){ console.log('sent form'); } </script> My question is: a) why does my console not log this when I submit? When I test using chrome, the console is empty after sending submit and b), how can I access the form's inputs from inside sendForm()? Do I need to reference that form directly or is there a way to just pass the data to sendForm() when I call it?
return false;tosendForm().console.logare async, never actually experienced that my self. Regardless, I dont that is relevant here.https://api.jquery.com/serializeArray/