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);