XMLHttpRequest是什么??( 二 )


//bstrPassword[可選]
//驗證信息中的密碼部分,如果用戶名為空,則此值將被忽略 。
//備注:調用此方法后,可以調用send方法向服務器發送數據 。
***.open("get","http://localhost/example.htm",false);
//varbook=xmlhttp.***.selectsinglenode("http://book[@id='bk101']");
//alert(***.xml);
//屬性:onreadystatechange
//onreadystatechange:指定當readyState屬性改變時的事件處理句柄
//語法:***.onreadystatechange=funcMyHandler;
//如下的例子演示當XMLHTTPRequest對象的readyState屬性改變時調用HandleStateChange函數,
//當數據接收完畢后(readystate==4)此頁面上的一個按鈕將被激活
//備注:此屬性只寫,為W3C文檔對象模型的擴展.
***.onreadystatechange=HandleStateChange;
//方法:send
//發送請求到http服務器并接收回應
//語法:***.send(varBody);
//參數:varBody(欲通過此請求發送的數據 。)
//備注:此方法的同步或異步方式取決于open方法中的bAsync參數,如果bAsync==False,此方法將會等待請求完成或者超時時才會返回,如果bAsync==True,此方法將立即返回 。
//Thismethodtakesoneoptionalparameter,whichistherequestBodytouse.TheacceptableVARIANTinputtypesareBSTR,SAFEARRAYofUI1(unsignedbytes),IDispatchtoanXMLDocumentObjectModel(DOM)object,andIStream*.Youcanuseonlychunkedencoding(forsending)whensendingIStream*inputtypes.ThecomponentautomaticallysetstheContent-LengthheaderforallbutIStream*inputtypes.
//如果發送的數據為BSTR,則回應被編碼為utf-8,必須在適當位置設置一個包含charset的文檔類型頭 。
//IftheinputtypeisaSAFEARRAYofUI1,theresponseissentasiswithoutadditionalencoding.ThecallermustsetaContent-Typeheaderwiththeappropriatecontenttype.
//如果發送的數據為XMLDOMobject,則回應將被編碼為在xml文檔中聲明的編碼,如果在xml文檔中沒有聲明編碼,則使用默認的UTF-8 。
//IftheinputtypeisanIStream*,theresponseissentasiswithoutadditionalencoding.ThecallermustsetaContent-Typeheaderwiththeappropriatecontenttype.
***.send(xmldoc);
//方法:getAllResponseHeaders
//獲取響應的所有http頭
//語法:strValue=https://www.myit5.com/shenghuo/***.getallresponseheaders();
//備注:每個http頭名稱和值用冒號分割,并以\r\n結束 。當send方法完成后才可調用該方法 。
alert(***.getallresponseheaders());
//方法:getResponseHeader
//從響應信息中獲取指定的http頭
//語法:strValue=https://www.myit5.com/shenghuo/***.getresponseheader(bstrHeader);
//備注:當send方法成功后才可調用該方法 。如果服務器返回的文檔類型為"text/xml",則這句話
//***.getresponseheader("Content-Type");將返回字符串"text/xml" ??梢允褂胓etAllResponseHeaders方法獲取完整的http頭信息 。
alert(***.getresponseheader("Content-Type"));//輸出http頭中的Content-Type列:當前web服務器的版本及名稱 。

猜你喜歡