I am learning how to work with XMLHttpRequests. I know that request.setRequestHeader() is an important factor. I just don't understand why. It took me a while but I have at least found a list of Headers here and here, but I still don't understand what each one of them does, and what value goes with each. Is there a resource that gives an example and explains what they are for?
closed as off-topic by amon, user40980, gnat, Bart van Ingen Schenau, World Engineer Mar 17 '14 at 14:09
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – amon, gnat, Bart van Ingen Schenau, World Engineer
A quick search found: http://code.tutsplus.com/tutorials/http-headers-for-dummies--net-8039
(no offense from the title; it looked like a pretty thorough article) Skip down to "HTTP Headers in HTTP Requests"
Just eyeballing the list, the most important headers are for "content negotiation":
Content-TypeMost servers will need this to parse & route your request to the right function:
AcceptTells the server what it can send back
AuthorizationIn my work, I usually have to provide an authorization key. But the server will tell you whether you need this or not.
Authorization: Bearer aasdadadadadadsasd
The other ones are either optional, or get added by the browser. You can open the dev console in your browser and look at the network messages going back and forth & do a search on individual headers to see what they mean.