INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

msxml2.xmlhttp never gets past readyState 1

msxml2.xmlhttp never gets past readyState 1

(OP)
Here's a code sample - I have response.writes put in to see what's going on:

CODE --> VBSCRIPT

dim o
set o = server.CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://www.url.com/", true
o.setRequestHeader "header1", "value1"
o.setRequestHeader "header2", "value2"
o.onreadystatechange = GetRef("checkReadyState")
o.send

sub checkReadyState()
	response.Write("1 - " & Now() & "<br />")
	response.Write("rs = " & o.readyState & "<br />")
	if o.readyState = 4 then
		response.Write("2 - " & Now() & "<br />")
		response.Write(o.responseText)
	else
		response.Write("3 - " & Now() & "<br />")
		response.Write("rs = " & o.readyState & "<br />")
	end if
end sub 

set o = nothing 

Here is the output I am getting:

1 - 11/6/2014 11:46:06 PM
rs = 1
3 - 11/6/2014 11:46:06 PM
rs = 1

Does this mean the onreadystatechange only fires once? Or is there some other problem?

RE: msxml2.xmlhttp never gets past readyState 1

You need to delay a bit before you terminate. The state change to 4 doesn't happen immediately. You need to hang around for at least 1 or 2 seconds.

RE: msxml2.xmlhttp never gets past readyState 1

I've converted your program to vbscript that you can run from a cmd prompt using

cscript //h:csrcript scriptname.vbs

CODE --> scriptname.vbs

dim o
set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://www.url.com/", true
WScript.echo "to start rs=" & o.readyState
o.setRequestHeader "header1", "value1"
o.setRequestHeader "header2", "value2"
o.onreadystatechange = GetRef("checkReadyState")
o.send
WScript.Sleep 5000
set o = nothing

sub checkReadyState()
	call WScript.echo("1 - " & Now() & "<br />")
	call WScript.echo("rs = " & o.readyState & "<br />")
	if o.readyState = 4 then
		call WScript.echo("2 - " & Now() & "<br />")
		call WScript.echo(o.responseText)
	else
		call WScript.echo("3 - " & Now() & "<br />")
		call WScript.echo("rs = " & o.readyState & "<br />")
	end if
end sub 
The results are

to start rs=1
1 - 09/11/2014 06:38:11<br />
rs = 1<br />
3 - 09/11/2014 06:38:11<br />
rs = 1<br />
1 - 09/11/2014 06:38:12<br />
rs = 4<br />
2 - 09/11/2014 06:38:12<br />

RE: msxml2.xmlhttp never gets past readyState 1

(OP)
Thanks for the reply - it still didn't work for me. Not sure what's going on. I figured out how to do it using JavaScript though, so it's all good.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close