老师,console报错
来源:2-2 创建XMLHttpRequest对象
qq_cookies_oqrHNO
2019-04-08 21:10:27
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<input id="btnload" type="button" value="加载">
<div id="divContent"></div>
</body>
<script>
document.getElementById("btload").onclick=function(){
//1.创建XmlHttpRequest对象
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
console.log(xmlhttp);
//2.发送Ajax请求
//3.处理服务器响应
}
</script>
</html>
package com.imooc.ajax;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class ContentServlet
*/
@WebServlet("/content")
public class ContentServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ContentServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().println("<b>I'm sever content</b>");
}
}
1回答
qq_cookies_oqrHNO
提问者
2019-04-08
检查出错误了,谢谢
相似问题