I'm trying to send XML data to a server using JavaScript through a POST request in a chrome extension though being new to JavaScript, I'm struggling. I don't know if it's even possible or not but here's what I have so far (the XML data is in the body of a html file in html format):
var http = new XMLHttpRequest();
var url = "(Server data upload service url)";
var params = encodeURIComponent(window.getElementsByTagName("body")[0].innerHTML);
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.send(params);
Any help is appreciated.