您的位置:程序门 -> vb -> 控件



xmlhttp中的readystate属性为什么永远是4


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


xmlhttp中的readystate属性为什么永远是4
发表于:2007-04-07 13:22:57 楼主
public   function   urlbodytxt(urlstr   as   string)   as   string  
dim   httpobj   as   new   msxml2.xmlhttp50  
dim   thetimeout   as   long  
httpobj.open   "get ",   urlstr,   true  

httpobj.send  
thetimeout   =   gettickcount()  
do  
if   httpobj.readystate   =   4   then  
if   httpobj.status   =   200   then  
urlbodytxt   =   bytestobstr(httpobj.responsebody,   "gb2312 ")  
else  
urlbodytxt   =   " "  
end   if  

exit   do  
end   if  

if   gettickcount()   -   thetimeout   >   6000   then  
urlbodytxt   =   " "  

exit   do  
end   if  
doevents  
sleep   200  
loop  
set   httpobj   =   nothing  
end   function  


我是用来测试是否能在6秒内打开我要打开的地址,由于是循环运行这个过程,只要运行后有一次readystate值达到了4(即成功访问到目标地址)后,那以后再运行到这里时,readystate的值就是一下子就到4了,运行open之前是0,open后是1,只要一运行send,那就直接到4
我在公司的电脑里调试完全没有问题,可回到家里同样是xp系统,为什么就会出现以上的问题
发表于:2007-04-07 14:34:031楼 得分:0
楼主readystate的值一下就到是就是表示数据已经是接受完毕了也就是没问题,你在家里跟公司的区别可能在与局域网能跟局域网外的区别,导致不能一下子到4!还有 "可回到家里同样是xp系统,为什么就会出现以上的问题 ",不明白楼主的意思是说什么问题?是不是我刚刚已经解答了!如果还有什么问题可于我qq联系739561543
发表于:2007-04-07 19:42:132楼 得分:0
我已经解决了,谢谢你


快速检索

最新资讯
热门点击