<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>first.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script>
var xhr;//全局变量
function fun()
{
var userName = document.getElementById('userName').value;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
//IE7 8
// xhr = new ActiveXObject("Msxml2.XMLHTTP");
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open('GET','DelUser.jsp?userName='+encodeURI(userName));
//xhr.open('post','DelUser.jsp');
//设置回调函数
xhr.onreadystatechange = function(){
var ready = xhr.readyState;
if (ready == 4){
parseCompletedResponse(xhr);
}
};
//xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.send(null);
}
function parseCompletedResponse(xhr)
{
var str = "<input type=text readonly value='"+xhr.responseText+"'/>";
document.getElementById('mm').innerHTML = str;
//alert(xhr.responseText);
}
</script>
</head>
<body>
<input type="text" id="userName" />
</br>
<div id="mm"></div>
<input type="button" value="Del" onclick="fun();" />
</body>
</html>
08-10
08-10