此小程序主要給ajax還未入門的朋友們一個簡單的演示
<!DOCTYPE HTML PUBLIC
<html>
<head>
<title>My JSP
<script type=
var req;
function createAJAX() {
if(window
req = new XMLHttpRequest();
} else if(window
req = new ActiveXObject(
}
}
function testAjax() {
var url =
createAJAX();
req
req
req
}
function callback() {
if(req
if(req
document
}
}
}
</script>
</head>
<body>
<input type=
可以根據下邊這個id號進行操作
</body>
</html>
說明
<?xml version=
<web
xmlns=
xmlns:xsi=
xsi:schemaLocation=
<servlet>
<servlet
<servlet
</servlet>
<servlet
<servlet
<url
</servlet
<welcome
<welcome
</welcome
</web
說明
package com
import java
import java
import javax
import javax
import javax
import javax
@SuppressWarnings(
public class TestAjaxServlet extends HttpServlet {
public void doPost(HttpServletRequest request
throws ServletException
response
String id = request
//可在此處判斷id是否為空
PrintWriter out = response
out
out
out
out
out
out
out
out
out
}
說明
結尾
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19365.html