mercredi 18 février 2015

XMLHttpRequest() post does not appear as file on server


As far as my limited understanding goes, this function should create a file on the server containing the text string returned by the function NewFileToSave():



function SaveDay()
{
var toSend = NewFileToSave();
var xhr = new XMLHttpRequest();
xhr.open('POST', 'postTest.dat', true);
xhr.onload =
function(e)
{
if (this.status == 200)
{
alert("Sent");
}
};
xhr.send(toSend);
alert(toSend);
}


When it runs (in Chrome, with no complaints from Chrome's Javascript console) the final alert gives me my text string as expected, and then the alert in the onload function tells me it's been sent, also as expected. But I get no server file called postTest.dat in the folder at the URL from which the HTML page containing the script was loaded into Chrome (or anywhere else on the server as far as a file search can tell).


Can someone please tell me how silly I am being?





Aucun commentaire:

Enregistrer un commentaire