0

I am using the following code and creating a dll using this. First time the send method woirks fine. From then onwards its giving the old values not the updated values

Dim xmlHttp As MSXML2.xmlHttp
Set xmlHttp = New MSXML2.xmlHttp
Dim response as string
response = xmlHttp.readyState
sUrl = "MyUrl"
xmlHttp.open "GET", sUrl, False
xmlHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
response = xmlHttp.readyState
xmlHttp.send

response = xmlHttp.readyState
response = xmlHttp.responseText
.....
Set xmlHttp = Nothing

Thanks Asha

Asha
  • 11
  • 1
  • 4
  • Perhaps you should read through http://stackoverflow.com/questions/5235464/how-to-make-microsoft-xmlhttprequest-honor-cache-control-directive – Bob77 Dec 26 '11 at 18:33
  • Do you actually recreate the object each time? – Deanna Oct 02 '12 at 10:01

1 Answers1

5

You can do a very simple trick to get always the updated values, you must have always a different URL. Add a parameter in the url that change every time you send the request, this parameter does nothing in server side in this example I create a static variable that increments at every call

Function GetHTMLSource(ByVal sURL As String) As String
Static id As Long
    id = id + 1
    If id >= 60000 Then
        id = 0
    End If
    Dim xmlHttp As Object
    Set xmlHttp = CreateObject("MSXML2.XmlHttp")
    xmlHttp.Open "GET", sURL & "?i=" & id, False
    xmlHttp.Send
    GetHTMLSource = xmlHttp.responseText
    Set xmlHttp = Nothing
End Function

good luck ;)

Deanna
  • 23,876
  • 7
  • 71
  • 156
ziedmaz
  • 51
  • 1
  • 3