下面是我的程序
HTML :
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript" language="javascript">
var xmlhttp;
function createXMLHttprequest()
{
if(window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
}
function inData()
{
var txtval=document.getElementById("txt").value;
createXMLHttprequest();
xmlhttp.open("GET","request.ashx?val="+txtval,true);
xmlhttp.onreadystatechange=getData;
xmlhttp.send(null);
}
function getData()
{
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
document.getElementById("showDT").innerHTML=xmlhttp.responseText;
}
}
}
</script>
</head>
<body>
<form action="">
<div>请输入姓名:
<input type="text" />
<input type="button" value="提交" />
<span ></span>
</div>
</form>
</body>
</html>
复制代码 代码如下:
<%@ WebHandler Language="C#" %>
using System;
using System.Web;
public class request : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string tab ="来自服务器的信息:您好 "+context.Request.QueryString["val"].ToString()+" --by time:"+DateTime.Now.ToLongTimeString();
context.Response.Write(tab);
}
public bool IsReusable {
get {
return false;
}
}
}
复制代码 代码如下:
var txtval=escape(document.getElementById("txt").value);
新闻热点
疑难解答
图片精选