嘗試 Server.CreateObject 實例化常見的 XMLHTTP ProgID,捕捉錯誤碼判斷是否支援。
test_xmlhttp.asp 上傳至空間訪問)<%
On Error Resume Next
Response.Write "<h3>伺服器 XMLHTTP 元件支援情況:</h3>"
Dim oxml, i, getxmlhttp
oxml = Array( _
"Msxml2.ServerXMLHTTP.6.0", "Msxml2.ServerXMLHTTP.5.0", "Msxml2.ServerXMLHTTP.4.0", _
"Msxml2.ServerXMLHTTP.3.0", "Msxml2.ServerXMLHTTP", _
"Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", _
"Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP" _)
For i = 0 To UBound(oxml)
Set getxmlhttp = Server.CreateObject(oxml(i))
If Err Then
Err.Clear
Response.Write oxml(i) & " 不支援<br/>"
Else
Response.Write oxml(i) & " 支援<br/>"
End If
Next
%>
ServerXMLHTTP 元件(共享主機常見),需詢問主機商或改用其他方案(如 cURL、WinHttp)。Msxml2.ServerXMLHTTP.6.0(Vista/Server 2008 內建,效能最佳)。