I'm encountering difficulties when trying to send a complete page source using AJAX. Despite attempting to escape the content with escape()
, encodeURI()
, and encodeURIComponent()
, I cannot successfully transmit utf8 characters.
Below is my code snippet:
var http = new XMLHttpRequest();
var send = params='html=' + encodeURIComponent(document.documentElement.outerHTML).replace('+',' ');
http.open('POST','submitsource.php',true);
http.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');
http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){
alert('ok!');
}};
http.send(params);