This link does a pretty good job of explaining and there are a couple of examples using PHP on the server side -
http://w3schools.com/ajax/default.asp
Basically, a http request is made to a URL (ie. yourscript.php). It is up to the server side code to receive any post/get data that is sent and change any variables. It is not possible to change any variables directly (unless you have register globals on.)