AJAX (Asynchronous JavaScript and Xml) is for communicating with a server. The following is an AJAX POST request that is being sent to test.php. PHP runs on servers and can receive, process, and respond to HTTP requests. You may want to look into PHP and server side web communications.
var myVar = "test";
$.ajax({
url: "test.php",
type: "POST",
data:{"myData":myVar}
}).done(function(data) {
console.log(data);
});
The accompanying PHP file may look something like:
<?php
$data = isset($_REQUEST['myData'])?$_REQUEST['myData']:"";
echo $data;
?>
These are very basic examples but can be very useful to learn.
AJAX tutorial: http://www.w3schools.com/ajax/
PHP tutorial: http://www.codecademy.com/en/tracks/php
.htmlfile do with the variable ?url: "test.html?var1=" + val1 + "&var2=" + val2