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

HTML

Explain GET and POST to me please

I am still confused on the GET and POST method, and when are you likely to use it in everyday web design?

Thanks

2 Answers

From the Treehouse Blog article The Definitive Guide to GET vs POST

Both HTTP methods can achieve the same goals, but an incorrect choice between them can lead to unexpected and potentially harmful outcomes.

GET VS POST BASICS

  1. Use GET for safe actions and POST for unsafe actions.
  2. Use POST when dealing with sensitive data.
  3. Use POST when dealing with long requests.
  4. Use GET in AJAX environments.

A few things to keep in mind when to using GET

  • GET requests can be cached
  • GET requests can remain in the browser history
  • GET requests can be bookmarked
  • GET requests can be distributed & shared

source: http://blog.teamtreehouse.com/the-definitive-guide-to-get-vs-post

Hi Kasim,

The GET and POST keywords are HTTP verbs as they describe a mode of transport, the most common use for them is in HTML <form> elements where you define a method which can be GET or POST, the difference is that GET simply passes data via the websites URL while POST uses HTTP headers to send data using application/x-form-urlencoded which allows a backend language such as PHP to access data through an previously empty array called $_POST but I won't get into that.

Depending on what your site needs to do depends on whether you need to worry about them as generally you would only require them if you did have a form on your site or have an ajax request that's retrieving content from the server on the fly.

You can read more about the HTTP world over at MDN.