So far as I know, the "open" method/function of an httpXMLrequest object has no return value. The question is whether it gets the value from the server for you.
void open(ByteString method, DOMString url, optional boolean async = true, optional DOMString? user = null, optional DOMString? password = null);
so yeah, undefined is to be expected.
change xmlreq.onreadystatechange = myFunc(); to xmlreq.onreadystatechange = myFunc; if you want the code to work as expected.