You must first understand that an AJAX request is an HTTP request. When you add
xmlhttp.setRequestHeader('Content-Type','XXXXXXXXX');
he adds a header that determines what data will be contained in the request body. application/x-www-form-urlencodedmeans that the data will be form data. The data format may be something else. This is precisely the fact that these forms are the most common that you will send to the server.
source
share