document load complete jquery 1

document load complete jquery

// jQuery document ready
$(document).ready(function() {

Here is what the above code is Doing:
1. We’re using jQuery’s document ready function to make sure the page is loaded before we try to do anything.
2. We’re using jQuery’s click function to listen for a click on the button with the id of “submit”.
3. When the button is clicked, we’re using jQuery’s ajax function to send a POST request to the URL /greeting.
4. We’re sending the data from the form with the id of “greeting-form” in the request.
5. We’re telling jQuery to replace the HTML of the div with the id of “greeting” with the response text.

Now, let’s add the HTML for the form and the div to our template:


Getting Started: Serving Web Content

Similar Posts