XMLHttpRequest是什么??( 二 )


//bstrPassword[可选]
//验证信息中的密码部分,如果用户名为空,则此值将被忽略 。
//备注:调用此方法后,可以调用send方法向服务器发送数据 。
***.open("get","http://localhost/example.htm",false);
//varbook=xmlhttp.***.selectsinglenode("//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" 。可以使用getAllResponseHeaders方法获取完整的http头信息 。
alert(***.getresponseheader("Content-Type"));//输出http头中的Content-Type列:当前web服务器的版本及名称 。

推荐阅读