Click here to Skip to main content
15,943,091 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a simple classic asp that uses a web service which returns a url that I need to display. I'm having problems displaying the returned string. I can not figure out the correct syntax to do this. Here is the code:

<title>Calling a webservice from classic ASP</title>
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim xmlhttp
Dim chartUrl
Dim DataToSend
Dim postUrl
postUrl = " http://localhost/edChartLink2/edChartLink2/edChartLink.asmx/GetToken"
Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
xmlhttp.Open "POST",postUrl,false
xmlhttp.setRequestHeader "Content-Type:", "application/x-www-form-urlencoded"
xmlhttp.send DataToSend & "
//chartUrl = xmlhttp.responseText


End If
<FORM method=POST name="form1">
Enter the two Values to be Added

<INPUT type="text" name="txtacctNum">
<INPUT type="text" name="txtMRN">

<INPUT type="submit" >

I get the url back in xmlhttp.reponsetext with no problem but I have tried using document.write windows.write in various formats and I still get an error.

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/edChartlink2/edChartlink2/Allscript2.asp, line 21

Can anybody shed some light on this and tell me what is the correct syntax.

Note: I'm new at this, thanks
Updated 21-Feb-11 2:06am

document object does not exist in VB. It's a javascript thingie and even in Javascript, document.write is a method and not a property. Should be used like

Share this answer
Sandeep Mewara 21-Feb-11 8:26am    
Comment from OP:
So how would I call the url from my code?

Yusuf 21-Feb-11 9:07am    
The OP is executing javascript on the server side of classic code. I don't think this will work. There is no document object for server side javascript code. He needs the Response object to write to the output stream.

Never mind, early monday morning, need to finish my cup of tea first. I thought he was using javascript, on second look he is using vbscript.
Manas Bhardwaj 21-Feb-11 9:14am    
The other responder has already explained the cause of the issue.

Just replace the line:


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.
Share this answer
Yusuf 21-Feb-11 9:08am    
This does not seem right solution, see my comment in Manas's answer.

Never mind, early monday morning, need to finish my cup of tea first. I thought he was using javascript, on second look he is using vbscript.
Ankur\m/ 23-Feb-11 0:01am    
:)BTW, in Classic ASP any scripting language including JavaScript can be used.
Yusuf 23-Feb-11 8:52am    
I know javascript can be used. Can you call the document DOM from the server side? like document.write
Ankur\m/ 23-Feb-11 9:09am    
Oh I see what you mean. AFAIK, you are correct. 'Document' is DOM object and must be present inside the script tag. How could a DOM object be processed on the server?!
I haven't tried it though.

Anyways I will edit my answer.
Thanks a lot! :)
Ankur\m/ 23-Feb-11 9:13am    
But it seems the solution worked for OP because he accepted the answer and haven't left any comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900