日期:2014-05-16 浏览次数:20445 次
/// <summary> /// 处理web请求 /// </summary> /// <param name="context"></param> public void ProcessRequst(HttpListenerContext context) { //得到请求 if (context.Response != null) { //得到html string strHtml = ControlManager(context); //返回客户端的html if (!string.IsNullOrEmpty(strHtml)) { byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strHtml); context.Response.ContentLength64 = buffer.Length; context.Response.KeepAlive = false; context.Response.OutputStream.Write(buffer, 0, buffer.Length); context.Response.OutputStream.Flush(); context.Response.OutputStream.Close(); } } }
function RequestTest() { var xmlHttp; var url = ""; if (window.ActiveXObject) { xmlHttp = new ActiveXObject("MSXML2.XMLHTTP"); } else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } xmlHttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { alert(xmlHttp.responseText); document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } } } xmlHttp.open("GET", url, true); xmlHttp.send(); }