posts - 66,  comments - 40,  trackbacks - 0

          ????這個(gè)標(biāo)題不知道怎么取才好,其實(shí)要實(shí)現(xiàn)的功能就是在客戶端要將大量的數(shù)據(jù)傳遞到服務(wù)端,我們知道url的長度是有限制的,如果使用url的參數(shù)來傳遞數(shù)據(jù),只能傳遞很少的關(guān)鍵信息,但有時(shí)候我們要傳遞大量的信息,比如一張單據(jù)中的所有商品的商品編號等等.
          ??? Ajax技術(shù)中的xmlhttp.send()方法提供我們傳送大量數(shù)據(jù)的功能,要使用該功能,首先要將要傳到服務(wù)端的數(shù)據(jù)封裝在一個(gè)xml對象中,在將這個(gè)xml對象的xml屬性做為send()方法的參數(shù)就可以.
          ??? 客戶端代碼:

          ???????????????????? 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);
          服務(wù)端需要從請求流中,解析出客戶端傳入的xml的內(nèi)容,服務(wù)端代碼:
          ????????????????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+"'";
          ????????????????}
          posted on 2006-08-08 18:12 happytian 閱讀(5224) 評論(3)  編輯  收藏

          FeedBack:
          # re: 使用xmlhttp.send()方法的參數(shù)來傳遞大容量的數(shù)據(jù)
          2007-09-28 15:40 | 狗的鼻子
          該問太好了,我正好碰到這個(gè)問題。拖福解決,對博主表示感謝!  回復(fù)  更多評論
            
          # re: 使用xmlhttp.send()方法的參數(shù)來傳遞大容量的數(shù)據(jù)[未登錄]
          2007-10-07 15:19 | happytian
          不客氣,互相學(xué)習(xí)
            回復(fù)  更多評論
            
          # re: 使用xmlhttp.send()方法的參數(shù)來傳遞大容量的數(shù)據(jù)[未登錄]
          2009-01-15 14:59 | xxx
          :)
          受教了  回復(fù)  更多評論
            

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          <2007年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          Welcome here, my friend!

          常用鏈接

          留言簿(12)

          隨筆檔案(66)

          文章分類

          文章檔案(63)

          web

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 89361
          • 排名 - 647

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 田林县| 曲松县| 合川市| 赤水市| 华蓥市| 苗栗县| 理塘县| 嘉祥县| 易门县| 华容县| 余江县| 富民县| 灌南县| 深州市| 江口县| 龙岩市| 石景山区| 秦安县| 丰城市| 上思县| 大丰市| 普格县| 新源县| 龙井市| 云南省| 游戏| 全南县| 彭州市| 读书| 西华县| 曲松县| 临洮县| 攀枝花市| 宽城| 青铜峡市| 大方县| 潜江市| 夏津县| 托克托县| 霍邱县| 新巴尔虎左旗|