open Method (IXMLHTTPRequest)
Initializes an MSXML2.XMLHTTP request and specifies the method, URL, and authentication information for the request.
oXMLHttpRequest.open(bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword);
Parameters
Example
The following JScript example creates an XMLHTTP object, and then uses the open method to get a copy of books.xml at the IIS Web server running locally. The code then selects the <book id="bk101"> element to display as output.
HRESULT open(BSTR bstrMethod, BSTR bstrUrl, VARIANT varAsync, VARIANT bstrUser, VARIANT bstrPassword);
Parameters
Return Values
Example
HRESULT hr; IXMLHttpRequest *pIXMLHttpRequest = NULL; try { // Create XMLHttpRequest object and initialize pIXMLHttpRequest. hr = pIXMLHttpRequest->open(_bstr_t(_T("PUT")), _bstr_t(_T("GET","http://MyServer/Sample.xml", false)), _variant_t(VARIANT_FALSE), _variant_t(""), _variant_t("")); if(SUCCEEDED(hr)) ::MessageBox(NULL, _T("Success !"), _T(""), MB_OK); } catch(...) { DisplayErrorToUser(); } // Release pIXMLHttpRequest when finished with it.
After calling this method, you must call send to send the request and data, if any, to the server.
Note
|
|---|
|
Although this method accepts credentials passed via parameter, those credentials are not automatically sent to the server on the first request. The bstrUser and bstrPassword parameters are not sent to the server unless the server challenges the client for credentials with a 401 - Access Denied response. |
Note