Witam serdecznie!
Skrypt JS pobiera do buforu żródło strony i przesyła je do skryptu PHP, który zapisuje wszystko w pliku tekstowym.
Problem polega na tym, że nie są zapisywane dane po wystąpieniu znaku "&". O co może chodzić?
skrypt.js
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
x = xhr.responseText;
http = new XMLHttpRequest();
var url2 = "http://localhost/root/parse.php";
var params = "msg="+x;
http.open("POST", url2, true);
http.setRequestHeader('Accept', 'text/html');
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.send(params);
}
}
xhr.open('GET', 'http://localhost/', true);
xhr.send(null);
parse.php
<?php
$DataFile = fopen("data.txt", "w") or die("Unable to open file!");
$Message = $_POST["msg"];
fwrite($DataFile, $Message);
fclose($DataFile);
?>
Pozdrawiam.