Skip to content

Instantly share code, notes, and snippets.

@binnng
Created December 23, 2013 14:43
Show Gist options
  • Save binnng/8098272 to your computer and use it in GitHub Desktop.
Save binnng/8098272 to your computer and use it in GitHub Desktop.
Use GET for AJAX Requests
Use GET for AJAX Requests
tag: server
The Yahoo! Mail team found that when using XMLHttpRequest, POST is implemented in the browsers as a two-step process: sending the headers first, then sending data. So it's best to use GET, which only takes one TCP packet to send (unless you have a lot of cookies). The maximum URL length in IE is 2K, so if you send more than 2K data you might not be able to use GET.
An interesting side affect is that POST without actually posting any data behaves like GET. Based on the HTTP specs, GET is meant for retrieving information, so it makes sense (semantically) to use GET when you're only requesting data, as opposed to sending data to be stored server-side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment