So I have this HTML file that tests the user\'s screen resolution, and plugins installed using Javascript. So when the user accesses the page it sees: (e.g.) Your current sc
Do you know jQuery? It will be much easier with jQuery.
var data = "";
for (var i=0; i < num_of_plugins; i++) {
var list_number=i+1;
document.write("<font color=red>Plug-in No." + list_number + "- </font>"+navigator.plugins[i].name+" <br>[Location: " + navigator.plugins[i].filename + "]<p>");
data += "<font color=red>Plug-in No." + list_number + "- </font>"+navigator.plugins[i].name+" <br>[Location: " + navigator.plugins[i].filename + "]<p>";
}
$.post('savedata.php', {data=data}, function(){//Save complete});
Then in savedata.php you can write something like the following:
$data = $_POST['data'];
$f = fopen('file', 'w+');
fwrite(f, $data);
fclose($f);
Without jQuery (raw JavaScript):
var data = "...";// this is your data that you want to pass to the server (could be json)
//next you would initiate a XMLHTTPRequest as following (could be more advanced):
var url = "get_data.php";//your url to the server side file that will receive the data.
var http = new XMLHttpRequest();
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);//check if the data was received successfully.
}
}
http.send(data);
Using jQuery:
$.ajax({
type: 'POST',
url: url,//url of receiver file on server
data: data, //your data
success: success, //callback when ajax request finishes
dataType: dataType //text/json...
});
I hope this helps :)
More info:
https://www.google.co.il/search?q=js+ajax+post&oq=js+ajax+post
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest
Do a request from javascript to a page which runs server side code.
Send post request with ajax http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml to for example an apsx page. From aspx you could save it to a text file or database.