zoukankan      html  css  js  c++  java
  • 使用xmlhttp.send()方法的参数来传递大容量的数据

    Ajax技术中的xmlhttp.send()方法提供我们传送大量数据的功能,要使用该功能,首先要将要传到服务端的数据封装在一个xml对象中,在将这个xml对象的xml属性做为send()方法的参数就可以.
        客户端代码:
                         var  guidArray = guidlist.split( " , " );
                        
    var  xmlDom = new  ActiveXObject( " MSXML2.DOMDocument " );
                        xmlDom.loadXML(
    "" );
                        
    var  domRoot =  xmlDom.createElement( " NewDataSet " );
                        xmlDom.appendChild(domRoot);
                        
    for ( var  i = 0 ;i < guidArray.length;i ++ )
                        {
                           
    var  node =  xmlDom.createElement( " guid " );
                           node.text
    = guidArray[i];
                           domRoot.appendChild(node);                       
                        }
                        
                        
    var  xmlhttp = new  ActiveXObject( " MSXML2.XMLHTTP " );                    
                        xmlhttp.onreadystatechange
    = function (){
                                
    if  (xmlhttp.readyState == 4 )
                                {
                                  
    if  (xmlhttp.status == 200 )
                                  {
                                     alert(
    " 处理完成 " );
                                  }
                                  
    else
                                  {
                                     alert(xmlhttp.responseText);  
                                  }
                                }
                                      
                        }
                        xmlhttp.Open(
    " POST " , " fmSmsPostProcess.aspx?sStatus= " + escape(sStatus) + " &sProcessResult= " + escape(document.getElementById( " btProcessResult " ).value) +
                                             
    " &sReStore= " + escape(document.getElementById( " btReStore " ).value), true );
                        xmlhttp.setRequestHeader(
    " Content-Type " , " text/xml " );                                         
                        xmlhttp.send(xmlDom.xml);
    服务端需要从请求流中,解析出客户端传入的xml的内容,服务端代码:
                    System.IO.Stream instream = Page.Request.InputStream;
                    BinaryReader br 
    = new BinaryReader(instream,System.Text.Encoding.UTF8);
                    
    byte[] byt = br.ReadBytes((int)instream.Length);
                    
    string sXml = System.Text.Encoding.UTF8.GetString(byt);

                    System.Xml.XmlDocument xmlDoc 
    = new System.Xml.XmlDocument();
                    xmlDoc.LoadXml(sXml);

                    XmlElement xe
    = xmlDoc.DocumentElement;
                    
    for(int i=0;i< xe.ChildNodes.Count;i++)
                    {
                        sGuid 
    = sGuid + ",'" + xe.ChildNodes[i].InnerText+"'";
                    }
  • 相关阅读:
    2018-2019-2 20165313 《网络对抗技术》Exp4 恶意代码分析
    2018-2019-2 20165313 Exp3 免杀原理与实践
    2018-2019-2 20165313 Exp2 后门原理与实践
    linux安装firmware-mod-kit
    暑假BUUCTF抄题记录
    手动编译Aseprite v1.2.21
    GameMaker Studio2 疑难杂症
    20181218 实验四《Python程序设计》实验报告
    20181218 实验三《Python程序设计》实验报告
    Mysql各种问题
  • 原文地址:https://www.cnblogs.com/ice5/p/1374315.html
Copyright © 2011-2022 走看看