Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed AJAX Basics!
You have completed AJAX Basics!
Preview
Learn about the two most common methods for sending requests to a web server. What is the difference between the two and when to use GET, when to use POST?
Key Points
There are two common methods for sending HTTP requests:
- GET. Used for most requests. Browser uses the GET method whenever it requests a new web page, CSS file, image, and so on. Use GET when you want to "get" something from the server.
- POST. Used frequently with web forms to send data to store in a database. Use POST when sending data that will store, delete or update information from a database.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
First you create the XMLHttpRequest
object, then you define
0:00
a callback function, you open the request,
and then you send it.
0:02
As I mentioned in the last video opening a
request requires specifying the method
0:07
you'll use to send the request and the URL
you'll send the request to.
0:12
The two most common methods are GET and POST.
0:16
Here's an easy way to think about which
method you should use.
0:20
Use GET when you're only interested in
0:23
receiving or getting information from a
server.
0:25
Such as the result of a database search or
retrieving a set of tweets.
0:28
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up