Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) AJAX Concepts GET and POST

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 298 Points

Question about GET, POST and REQUEST

This is more of a comment than a question, but I find it confusing that, as I understand it, you make a request to the server from the client/browser whether you are getting something with GET -- a webpage, for instance -- or giving something with POST -- the data from a form field, for instance. The word REQUEST implies that you want something in return. The terminology makes sense where GET is concerned: the browser makes a request to the server and gets something in return, but when it comes to POST, it's more like the browser is giving something to the server. What are you "requesting" when you POST? I give props to teacher for at least attempting to disambiguate the term "call back". They never bother to do this on Lynda.com, anywhere on Pluralsight (that I've seen), or Code School. If you Google the term, you get tech speak mumbo jumbo in the first few results.

I think of it like this...

You are requesting the server do something for you. You want it to get information for you, or post the information you give it on the server.

Either way you are requesting the server to do some action. The action being get or post.

4 Answers

you can think of it as a different layer in the communication

for example if you are calling your friend on the phone and ask for directions (GET) vs you are calling your friend to give directions to your house (PUT)

since it all starts with you picking up the phone, IE you are making the call it's still a Request your friend picks up and it's a Response

If your friend doesn't answer it's a 404

Kevin Korte
Kevin Korte
28,149 Points

I'm going to focus my answer here:

but when it comes to POST, it's more like the browser is giving something to the server. What are you "requesting" when you POST?

as this seems to be where you are hung up.

What you are requesting is updated information, from both get and post. You, as the developer have to give your post requests and exit strategy. Common examples for post request are

  • What happens after a user logs in?
  • What happens after a contact form is submitted?
  • What happens after a user pays with their card online?

You have to decide. Typically with a get request you are going to give the server some information via the get action, ad typically you would use the servers response to show something based on that get response. It might be search results, maybe a post filter. Post does the same, except you send the request via post and you still want the server to show something based on the post response. Could be a client logged in, could be a thank you page.

As a developer you are responsible for what and how you give information to the server, what the server does, and how the server responds. There are just two different ways to wrap up those requests and send them, get and post. Both are actionable events.

Carlos Colon
Carlos Colon
12,758 Points

Not sure if a "Curse of Knowledge" (i.e., " cognitive bias that leads better-informed parties to find it extremely difficult to think about problems from the perspective of lesser-informed parties") applies here. The main issue here is, as you asked, "What are you "requesting" when you POST?". Simply put, when you make a "Request" you are asking somebody to do something. In this case, you are asking them one of two things. Either A) Hey, can you 'GET' this information? or B) can you 'POST' this information? In both scenarios what you are getting in return is the person (i.e., server) completing the request. I don't really understand what is bias about this response. This is not an issue of terminology because whether it's Get or Post it is still a Request

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 298 Points

I think I still have a point (which no one is their response object has acknowledged ; ). The terminology is confusing. Nothing anyone can do about that. Nonetheless, it takes a bit of effort for a teacher to sort it out carefully. Otherwise there is room for confusion. There are a lot of things on learning sites like this one (and all others, to be fair) which could be explained a little more carefully, not that I don't recognize and appreciate the effort that is being made. There's actually a term for this called The Curse of Knowledge which you can read about here if you'd like: https://en.wikipedia.org/wiki/Curse_of_knowledge