This is very new to me, so apologies if these are obvious questions:
I would like a button on a web page to run a server side function and return the output to the client, would the following be the correct method?
- Button calls client side function
- Client side function makes an AJAX request to a .js file on the server, which runs the function specified in the AJAX request.
- The result of the server side function is sent back to the client and can be used to modify the web page content.
If this is the correct method, what would the (vanilla, preferably) AJAX request look like?
My final question is, are only scripts listed within the HTML documents of the webpages downloaded to the client?
I'm sure these are both simple questions, but thank you nonetheless.