The other responder has already explained the cause of the issue.
Just replace the line:
document.write=xmlhttp.responseText
with
document.write(xmlhttp.responseText)
and it should work fine.
As Yusuf pointed out that
document
is a DOM object and couldn't be processed at server side.
You are already writing the value of
xmlhttp.responseText
to the
Response
, what the next line is for?
Commenting that line should work fine.