Thank you for the response.
I forgot when composing the post above that method
has a special meaning. I should have used the word ‘technique’ or ‘tool’. The vocabulary is not second nature to me yet.
I understand what APIs are, that they may be private, public, etc. They are simply the rules by which different applications communicate intelligibly.
What I’m trying to understand is how data to be sent - from a form, for example, is actually organized and sent. Suppose I have defined a form using HTML/CSS with various input areas defined. Suppose further that I have written code that will do frontend data validation and that my user has complied with all the constraints that code requires . . . IOW, the data is ready to send to a backend that has code that will a) further process/validate the data sent; b) update a database (using SQL, in my case); and respond to my user that the update succeeded or that the data must be changed. In that case, what code, if any, is needed on the frontend to prepare the data to be sent? What code, if any, is required to actually cause the data to be transmitted to the backend API?
I understand that a form
element defines an action
and a method
(and perhaps an id
). As I understand it, the action
attribute defines the action to be performed when the form is submitted. In examples I’ve seen the value is often a file name preceded by a path or URL, indicating to me that the data from the form will be sent to the named resource as a file.
Suppose I coded a form like this:
<form id="example" action="*somefile.js*" method="post">
<label for="firstName"></label>
First Name:
<input type="text" id="firstName" name="firstName" >
<label for="lastName">Last Name:</label>
Last Name:
<input type="text" id=lastName" name="lastName">
</form>
Suppose a user, having correctly entered the names, would click a SUBMIT button (not defined above, nor is any frontend data validation code). What would happen?
The <form action=somefile.js . . .
does what, exactly?
The <form . . . . method="post">
will indicate to the backend to use the date (first and last names) to update a database, among other things perhaps.
In the example above, there is no javascript or other script. Is any needed to send the names to the backend? If not, why not?
It’s my understanding that HTML simply turns on an ‘event’ switch to indicate the button has been clicked but that it does not take ant other action. Do I misunderstand this?
From all I’ve read, javascript (or some other code) would have to ‘listen’ for (test the clicked-event switch) the clicked event and do some processing. Presumably, after testing that the values entered for the names were text, something would have to be coded to cause the file - somefile.js - in my example to be created with appropriate information for the API to process it AND some code would have to cause the client computer to send the file. How is this done? . . . a javascript function
or other statement? Would a JSON element/value pair array be created, for example?