In book JavaScript: The Definitive Guide, 5th Edition by David Flanagan, says: before sending AJAX request, you have to send request headers.
In a scope of cross browsers support, do I need to do that?
request.setRequestHeader("User-Agent", "XMLHttpRequest");
request.setRequestHeader("Accept-Language", "en");
request.setRequestHeader("If-Modified-Since", lastRequestTime.toString());
For the last 2 header, they are not mandatory at all for browser compatibility. Those header are used as preference indication (Accept-Language) and content optimization (If-Modified-Since).
The first header is used on the server side to detect whether a query was done from AJAX or simply navigation. Older browser may not set this header by default, so you can lose browser compatibility if your server relies on this header to be set. If your server doesn’t relies on this header to be set, you won’t lose any browser compatibility if it’s not set.
Note that the first header should be
X-Requested-Withand notUser-Agent.