Attaching the AJAX Request Function to the Form - AJAX
In the first part, you learned about CSS and some basic tips/techniques for using the slider to display colors. In this part, we will discuss how we are going to write our AJAX and PHP scripts to make our user-defined CSS website.
The name of the AJAX function is sendRequest(). One of the common techniques for attaching the AJAX function involves using the JavaScript onClick event; however, we already have one function attached to the onClick event in the form (grabcolor(), the color-grabbing function).
In order for the form to send the request to AJAX the moment the submit button (Customize webpage color) has been clicked, we can add another function to the onClick event. This can be done by modifying the existing onClick event to:
onClick="grabcolor();sendRequest()"
This technique is commonly called "executing multiple JavaScript functions in one onClick event."