日期:2014-05-17 浏览次数:20420 次
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="Stylesheet" type="text/css"/>
<script src="yanzheng.js" language="JavaScript" type="text/javascript"></script><%--调用写异步ajax的JS文件--%>
</head>
<body>
<form id="form1" runat="server">
<div class="message">
<table>
<tr>
<td class="Writing" align="right"><asp:Label ID="Label1" class="LabelClass" runat="server" Text="昵称:"></asp:Label></td>
<td class="Box"><input id="w_name" class="TextBoxStyle"
onkeyup="CheckUserName(this.value)"/></td> <%--这里放一个input获取用户输入--%> <td><div id="msg"></div></td><%--这里放一个DIV显示ajax处理回调后的结果--%
</tr>
</table>
</div>
</form>
</body>
var xmlHttp;
//声明XMLHttpRequest对象
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//处理发送请求
function CheckUserName() {
createXMLHttpRequest();
var strName = document.getElementById("w_name").value;
var url = "Handler.ashx?strUserName=" + strName;