1个回答
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@page import="java.util.Enumeration"%>
<html>
<head>
<title>test-get_post</title>
<script src="demo.js" type="text/javascript"></script>
<script type="text/javascript">
<!--//
var request = getXMLHttpRequest();
function getFormInfo() {
var postBody = serializeForm('Login');
var url = document.getElementById('Login').action;
request.open("post", url, true);
request.onreadystatechange = updatePage;
//
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send(postBody);
}
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var response = request.responseText;
alert(response);
} else
alert("status is " + request.status);
}
}
//-->
</script>
</head>
<body>
<form id="Login" name="Login" method="post" action="result.jsp">
User ID: <input type="text" name="name"><br>
Password: <input type="password" name="password"><br>
sex:<input type="radio" name="sex" value="man"> man <input type="radio" name="sex" value="woman"> woman<br>
interest:<input type="checkbox" name="interest" value="piu">PIU <input type="checkbox" name="interest" value="dss">DSS <input type="checkbox" name="interest" value="ddr">DDR<br>
<input type="hidden" name="from" value="welcome"><br>
<input type="button" name="submit" value="submit" onclick="getFormInfo();">
</form>
</body>
</html>
<%@page import="java.util.Enumeration"%>
<html>
<head>
<title>test-get_post</title>
<script src="demo.js" type="text/javascript"></script>
<script type="text/javascript">
<!--//
var request = getXMLHttpRequest();
function getFormInfo() {
var postBody = serializeForm('Login');
var url = document.getElementById('Login').action;
request.open("post", url, true);
request.onreadystatechange = updatePage;
//
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send(postBody);
}
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200) {
var response = request.responseText;
alert(response);
} else
alert("status is " + request.status);
}
}
//-->
</script>
</head>
<body>
<form id="Login" name="Login" method="post" action="result.jsp">
User ID: <input type="text" name="name"><br>
Password: <input type="password" name="password"><br>
sex:<input type="radio" name="sex" value="man"> man <input type="radio" name="sex" value="woman"> woman<br>
interest:<input type="checkbox" name="interest" value="piu">PIU <input type="checkbox" name="interest" value="dss">DSS <input type="checkbox" name="interest" value="ddr">DDR<br>
<input type="hidden" name="from" value="welcome"><br>
<input type="button" name="submit" value="submit" onclick="getFormInfo();">
</form>
</body>
</html>
追问
demo.js
在哪呀?
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询