活不明白

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

function AjaxData(url, domId){
 var http_request = null;
 if (window.XMLHttpRequest) {
  http_request = new XMLHttpRequest();
  if (http_request.overrideMimeType)
   http_request.overrideMimeType('text/html');
 } else if (window.ActiveXObject) {
  try {
   http_request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {}
  }
 }
 if (http_request==null)
  return false;
 
 http_request.onreadystatechange = function(){
  if (http_request.readyState == 4) {
   if (http_request.status == 200) {  
   
   document.getElementById(domId).innerHtml=http_request.responseText;   
   //alert(document.getElementById(domId).innerText);
   } else {
    return false;
   }
  }
 }
 http_request.open("POST", url, true);
 http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 http_request.send();
 return true;
}

function AjaxSendData(url,func){
 var http_request = null;
 if (window.XMLHttpRequest) {
  http_request = new XMLHttpRequest();
  if (http_request.overrideMimeType)
   http_request.overrideMimeType('text/html');
 } else if (window.ActiveXObject) {
  try {
   http_request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {}
  }
 }
 if (http_request==null)
  return false;
 
 http_request.onreadystatechange = function(){
  if (http_request.readyState == 4) {
   if (http_request.status == 200) {
   func(http_request.responseText);   
   } else {
    return false;
   }
  }
 }
 http_request.open("POST", url, true);
 http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 http_request.send();
 return true;
}

假如send方法发送了数据,则可以这样来获取send过来的数据
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);

posted on 2007-12-29 13:48  Rain@sz  阅读(281)  评论(0编辑  收藏  举报