已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
function posthtm(url,id,verbs,is)var doc = document.getElementById(id);doc.innerHTML=Loading.;var xmlhttp = false;if(doc!=null)doc.style.visibility=visible;if(doc.style.visibility=visible)xmlhttp=ajax_driv();xmlhttp.open(POST, url,true);xmlhttp.onreadystatechange=function() if (xmlhttp.readyState=4) if (is)doc.innerHTML=xmlhttp.responseText;elseeval(xmlhttp.responseText);xmlhttp.setRequestHeader(Content-Length,verbs.length);xmlhttp.setRequestHeader(CONTENT-TYPE,application/x-www-form-urlencoded);xmlhttp.send(verbs);微软的JavaScript,Post的实例(XMLHTTP) 下面这个functioon是我分析MSN的一个网址截取的,对使用javascript Post数据的时候有用,以前我都是用笨办法在页面上放个隐藏的form然后submit,现在可以直接用使用post了,_!function_sd_Post(Url,Args) varxmlhttp; varerror; eval(tryxmlhttp=newActiveXObject(Microsoft.XMLHTTP);catch(e)xmlhttp=null;error=e;); if(null!=xmlhttp) xmlhttp.Open(POST,Url,false); xmlhttp.setRequestHeader(Content-Type,application/x-www-form-urlencoded); xmlhttp.Send(Args); strText=xmlhttp.responseText; /ifourresponsestartswithhttpthanredirectthere if(strText!=null&strText.toLowerCase().indexOf(http)=0) location.href=strText; else location.href=c_errorUrl; returnstrText; functionGetActionUrl(listKey) returndocument.getElementById(ActionUrl:+listKey).url 靠!下面是从Google搜索到的更有用的,哈哈!/Web/Web_Languages/Q_21132871.html SolutionTitle:Microsoft.XMLHTTPsendingafile askedbymikevandikeon09/15/200404:21PMPDT HiIamcurrentlyre-developingawebbasedfrontendforanestateagenttomanagetheirpropertys.IhavedecidedtouseaMicrosoft.XMLHTTPobjecttocommunicatebetweentheclientandserver.Myproblemisgottodowithsendingafilewiththis.TheclientiscomposedoftheusualGUIcomponentswhichthedatacanbeeasilyretrievedfromforsendingtotheserverbutitalsocontainsafileelementforselectingapictureofthepropertytobeuploaded.HowdoIgetthedatafromthissothatitcanbeuploadedtotheserverusingtheMicrosoft.XMLHTTPobject.IhavefoundabitofcodeonthenetbutitisnousetomebecauseitwouldinvolvechangingthesecurityinInternetOptionswhichIhavenocontrolover. FileSend Ready /filesuploadfunction functionbtn_send.onclick() /createADO-streamObject varado_stream=newActiveXObject(ADODB.Stream); /createXMLdocumentwithdefaultheaderandprimarynode varxml_dom=newActiveXObject(MSXML2.DOMDocument); xml_dom.loadXML(); /specifynamespacesdatatypes xml_dom.documentElement.setAttribute(xmlns:dt,urn:schemas-microsoft-com:datatypes); /createanewnodeandsetbinarycontent varl_node1=xml_dom.createElement(file1); l_node1.dataType=bin.base64; /openstreamobjectandreadsourcefile ado_stream.Type=1;/1=adTypeBinary ado_stream.Open(); ado_stream.LoadFromFile(c:sold.gif); /storefilecontentintoXMLnode l_node1.nodeTypedValue=ado_stream.Read(-1);/-1=adReadAll ado_stream.Close(); xml_dom.documentElement.appendChild(l_node1); /wecancreatemoreXMLnodesformultiplefileupload /sendXMLdocumentotoWebserver varxmlhttp=newActiveXObject(Microsoft.XMLHTTP); xmlhttp.open(POST,,false); xmlhttp.send(xml_dom); /showservermessageinmessage-area div_message.innerHTML=xmlhttp.ResponseText; thanks John. 其他资源.The HttpRequest object provides client-side communication with a server.ExamplesreadyState How to return the state of the document. This property changes as the document is being loaded. responseText How to return the request as a string. status How to return the status of the operation, as a code. statusText How to return the status of the operation, as a string. The HttpRequest objectWith the httpRequest object you can send a request from the client to the server.If you are using JavaScript in IE 5.0, you can create the HttpRequest object with the following code:var xmlHTTP = new ActiveXObject(Microsoft.XMLHTTP)If you are using VBScript you create the httpRequest object with the following code:set xmlHTTP = CreateObject(Microsoft.XMLHTTP)The httpRequest object is not a part of the W3C DOM standard.Get XMLHow to get an xml file from the server using the httpRequest object (works only in IE):var xmlHttp = new ActiveXObject(Microsoft.XMLHTTP)xmlHttp.open(GET, note.xml, false)xmlHttp.send()xmlDoc=xmlHttp.responseTextTry it Yourself Netscape compatible code: xmlHttp = new XMLHttpRequest();xmlHttp.open(GET, note.xml, false);xmlHttp.send(null);xmlDoc = xmlHttp.responseText;Try it Yourself Send XMLYou can also send an xml document to an ASP page on the server, analyze the request, and send back the result.var xmlHttp = new ActiveXObject(Microsoft.XMLHTTP)xmlHttp.open(POST, demo_dom_http.asp, false)xmlHttp.send(xmlDoc)document.write(xmlHttp.responseText)The ASP page, written in VBScript:set xmldoc = Server.CreateObject(Microsoft.XMLDOM)xmldoc.async=falsexmldoc.load(request)for each x in xmldoc.documentElement.childNodes if x.NodeName = to then name=x.textnextresponse.write(name)You send the result back to the client using the response.write property.Try it Yourself Important NoteAt the moment, the Microsoft XMLHTTP object can only be run in the BROWSER.SERVER code that attempts to use the XMLHTTP to communicate with other Web servers, may function incorrectly or perform poorly.This is a bug in the HTTPRequest object. For more information read Microsofts Knowledge Base article Q237906. The rumor is that Microsoft will have this bug fixed in an upcoming release of the XML Library. In the meantime, you may have to use a commercially available ASPHTTP component.The httpRequest PropertiesProperty Description readyStateReturns the state of the documentresponseBodyReturns the response as an array of unsigned bytesresponseStreamReturns the response a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 设备租赁合同管理流程指南
- 2025年5G通信行业品牌保护与市场拓展可行性分析报告
- 2025年智能家居产品市场份额调研报告
- 2026年远程医疗健康数据监测方案
- 2026年物流配送路径规划节能降耗方案
- 物流配送路径优化运输成本降低项目方案
- 多播寻址在智能组网中的创新应用-洞察及研究
- 濒危语言的公众认知度研究-洞察及研究
- 膜分离技术与分离工艺优化-洞察及研究
- 2025年工业车辆销售合作合同样本
- 救生衣项目创业计划书
- 数字货币概论 课件 第5章 稳定币的原理与实现
- FZ∕T 61002-2019 化纤仿毛毛毯
- 耳穴压豆教学课件
- 大学成长规划计划
- 坚持立足中国又面向世界讲解
- 2023年佛山市南海区散装水泥办公室招考公益一类事业编制工作人员考前自测高频考点模拟试题(共500题)含答案详解
- 集成运算放大器及应用-集成运算放大器(电子技术课件)
- 大学英语四级单词表(高中没学过)
- 内蒙古平煤阿鲁科尔沁旗煤业有限责任公司爱民温都煤矿采矿权出让收益评估报告
- 电气接线工艺培训
评论
0/150
提交评论