asp代码
<%
Response.Charset="gb2312"
username=Request.QueryString("username")
if username="127" then
Response.write username
Response.Write "正确"
else
Response.write username
Response.Write "错误"
end if
Response.Write "<br>怎么样显示汉字"
Response.End()
%>
html代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
var rtnStr=""
var httpRequest=null
function sendRequest(sndStr) {
if(window.XMLHttpRequest)
{ //Mozilla 浏览器
httpRequest = new XMLHttpRequest();
}else if (window.ActiveXObject)
{
var msxmls = new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');
for (var i = 0; i < msxmls.length; i++)
{
try
{
httpRequest = new ActiveXObject(msxmls[i]);
}catch (e) {
}
}
}
if (httpRequest != null)
{
httpRequest.onreadystatechange=processRequest
httpRequest.open("GET", sndStr, true);
httpRequest.send(null);
}else{alert("你的浏览器不支持XMLHttpRequest对象")}
}
processRequest=function () {
if (httpRequest.readyState == 4)
{ // 判断对象状态
if (httpRequest.status == 200)
{ // 信息已经成功返回,开始处理信息
rtnStr=httpRequest.responseText;
} else { //页面不正常
alert("您所请求的页面有异常。");
}
}else {
//alert("loading...")
}
}
var i=0
function userCheck() {
sendRequest("ajax.asp?username="+document.getElementById("username").value)
document.getElementById("box").innerText=rtnStr
}
</script>
</head>
<div id="box"></div>
<body>
<form name="form1" action="" method="post">
用户名:<input type="text" name="username" value="">
<input type="button" name="check" value="唯一性检查" onClick="userCheck()">
<input type="submit" name="submit" value="提交">
</form>
</body>
</html>