Since your question is kind of "please do my own homework", my answer points to a good site were you can do your own assignments: http://ajaxpatterns.org/XMLHttpRequest_Call
What you want to do is to use xmlHTTPRequest() object in a javascript to post data to a webserver and read the response.
The page linked above has a broken link to a demo, here is the right one: http://ajaxify.com/run/xmlHtttpRequestCall/
and the source of the page is very interesting, for example please consider this snippet:
function createXMLHttpRequest() {
try { return new XMLHttpRequest(); } catch(e) {}
alert("XMLHttpRequest not supported");
return null;
}
var xhReq = createXMLHttpRequest();
xhReq.open("GET", "sumGet.php?figure1=5&figure2=1", false); //here method of sending data and server page where to send to
xhReq.send(null);
var serverResponse = xhReq.responseText;
$("response").innerHTML = serverResponse;