I use ajax to send text to my server. If I remove the line below it breaks.
xhr = new window.XMLHttpRequest();
xhr.open("POST", config.url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // removal causes error
I noticed that my get requests do not require a request header. In fact this is the only requestHeader I have ever used.
What exactly is x-www-form-urlencoded and why is it needed?
How / Does it relate to encodeURIComponent ,which I found that I must also run on text sent to the server?