You are trying to make the call *asynchronously* (which means "don't wait for the answer") and so then you are trying to get the status before the answer is received. So of course you get the error.
Also, you test on the status is backwards. "200" means "ok".
So...
<script language="VBScript">
msgbox urlget("http://www.google.com")
Dim strPageStat
Function URLGet(URL)
Set Http = CreateObject("Microsoft.XMLHTTP")
Http.Open "GET", URL, False ' False means *synchronous*
Http.Send ()
strPageStat = Http.Status
if strPageStat <> "200" then
URLGet="Error:"& strPageStat
else
URLGet = Http.responseText
end if
End Function
</script>
If you really want to do this asynch, you need to use the same kind of state change handler you would for Ajax.
|