<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
function ajaxEx() {
alert("hello");
var name = document.insertForm.T_name.value;
alert(name);
var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
var url ="searchAction?T_name="name;
xmlHttp.open("post",url,true);
xmlHttp.onreadystatechange=function (){
if(xmlHttp.readystate == 4){
resultDiv.innerHTML +=xmlHttp.responseText;
}
else{
alert("hello");
}
}
xmlHttp.send();
}
</script>
<form method="post" name="insertForm" style="margin-bottom: 50px;margin-top: 50px;">
请输入要查询的图书的信息:<br/>
<br /> 名称:<input type="text" name="T_name" onkeyup="ajaxEx()">
</form>
<hr>
书籍信息<br>
<ul style="height: 0px ;padding: 0px;margin: 0px;">
<li style="width: 80px;display: inline-block;list-style: none;">名称</li>
<li style="width: 40px;display: inline-block;list-style: none;">编号</li>
<li style="width: 40px;display: inline-block;list-style: none;">价格</li>
</ul><br/>
<div id="resultDiv">
</div>
</body>
</html>
# 去掉这部分之后,js就可以弹出了“hello”
xmlHttp.open("post",url,true);
xmlHttp.onreadystatechange=function (){
if(xmlHttp.readystate == 4){
resultDiv.innerHTML +=xmlHttp.responseText;
}
else{
alert("hello");
}
}
xmlHttp.send();
js加入ajax代码之后,js不起作用了
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
9条回答
- Go 旅城通票 2015-10-27 05:38关注
var url ="searchAction?T_name="name;
==>>
var url ="searchAction?T_name="+name;
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 程序不包含适用于入口点的静态Main方法
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记