Trying to retrieve a remote page and include it in the current document. Assume it like, toplist java codes or ad network codes. I dont know Ajax or Java much , going through examples, i model something like the following:

Scenario is calling source.js?id=XX which will output source.php?id=XX
document.write part is wrong i guess, however i dont know how to output response data in Java, anyone to help me?

var xmlHttpReq = false;
var self = this;
var URL = "";
URL+= "?id="+escape(id);

if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject(\"Microsoft.XMLHTTP\");
}'GET', URL, true);

if (self.xmlHttpReq.readyState == 4) {
document write (self.xmlHttpReq.responseText);