For example, suppose I'm using AJAX to send a request to a server like so:
$.ajax(
{
url: url,
beforeSend: function (request) { request.setRequestHeader('X-Test', 'one'); },
});
The documentation for $.ajax
contains the following:
contentType (default: 'application/x-www-form-urlencoded; charset=UTF-8') Type: String
When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding.
According to this, the default is UTF-8, but I'm not clear from the description if the contentType
header affects only the encoding of the request's body or the encoding of the other headers as well (if the latter can even be changed).