2011-12-26 11 views
0

私は次のコードを使用しており、これを使用してDLLを作成しています。初めてsendメソッドがうまく動く。その後、以降そのあなたは常に更新された値を取得するために非常に単純なトリックを行うことができます古い値ではない更新された値MSXML2.xmlHttpのメソッドを2回目送信しない

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 

おかげ アシャ

+0

おそらくあなたはhttp://stackoverflow.com/questions/5235464/how-to-make-microsoft-xmlhttprequest-honor-cache-control-directiveを読むべきです – Bob77

+0

毎回オブジェクトを実際に作り直していますか? – Deanna

答えて

4

を与えてから、あなたは常に別のURLを持っている必要があります。 )

を、 は、私はすべての呼び出し

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 

幸運でインクリメント静的変数を作成するには、リクエストを送信するたびに変更するURLにパラメータを追加し、このパラメータは、この例では、サーバ側 で何もしません

関連する問題