JavaScript. XMLHttpRequest. POST requests. Make simple comment form with ajax

Home » Tutorials » JavaScript » JavaScript. XMLHttpRequest. POST requests. Make simple comment form with ajax
In last lesson we considered GET requests with xmlhttprequest. In this lesson we’ll discuss how to make post requests with this object.
The differences between GET and POST is the way to pass data. IN GET data is passed in url. IN POST data is passed in request body. Furthermore you must set http header with setRequestHeader method.
It is important to remember that we work with user’s data. That’s why we must protect our projects. You need to use encodeURIComponent method to remove unwanted data. During call send method you must pass body parameter. In example below this is body variable.
Also we’ll make little pretty project – simple comment form.
Task description: we enter comment text and this text inserts to database and reads from database to page with list comments.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

Pin It on Pinterest

Share This