XMLHTTPRequest Freez... why?

I am using visual basic 6 for send request to server and following are the code

Dim objXml As MSXML.XMLHTTPRequest
Set objXml = New XMLHTTPRequest
objXml.Open "POST", "Some http url" , False
objXml.setRequestHeader "content-type", "application/x-www-form-urlencoded"
objXml.send ("") ' >> Freezing point
debug.pring objXml.responseText

it working perfect.. but

prblem is that when i objxml send request (mention in red color) it freez is their any solution for that or any other alternet..

Thanks in advance..




Answer this question

XMLHTTPRequest Freez... why?

  • ADPerkin

    Thank You,
    Young Joo

    it really help me a lot.



  • IMBack

    First thing to check is to see if the server is responding at all. If server is not responding then your application might hang waiting for the response at send() method and eventually timeout.

    Your open() method has varAsync parameter (third one) set to False which makes your send() call synchronous. That means send() won't return until either entire response has been received or time out is detected.

    You can set the parameter to True, call send() and enter into a loop to check for response. You can add your own logic to decide what to do if you do not receive response within whatever amount of time you want to wait.

    Since client code should not rely on the health of network connection (whether it's local network or Internet), you should not use synchronous send() method. Always use asynchronous send() so that you can provide alternative experience to users in case something goes wrong.

    More information on XMLHTTPRequest members from below link:
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/xmlsdk/html/7924f6be-c035-411f-acd2-79de7a711b38.asp



  • yjoe3

    Thats my final code.

    Dim objXml As MSXML.XMLHTTPRequest
    Set objXml = New XMLHTTPRequest
    objXml.Open "POST","some url", True
    objXml.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    objXml.send ("")

    Do While objXml.readyState <> 4
    DoEvents
    Loop



  • XMLHTTPRequest Freez... why?