Jsp中用ajax取得数据的时候,在form标签中的时候,取到的数据写不到DIV中
时间:2011-01-22
来源:互联网
脚本
var xmlHttpReq;
function createXMLHttpRequest() {
if (xmlHttpReq == null) {
if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
} else {
xmlHttpReq = new XMLHttpRequest();
}
}
}
function sendReq(Model) {
document.getElementById("SearchStation").value = Station;
createXMLHttpRequest();
var sendTime = new Date();
var url = "servlet/getStationInfo?Model=" + Model;
xmlHttpReq.open("GET", url, true);
xmlHttpReq.onreadystatechange = showResult;
xmlHttpReq.send();
}
function showResult() {
if (xmlHttpReq.readyState == 4) {
if (xmlHttpReq.status == 200) {
var result = xmlHttpReq.responseText;
alert(result);
document.getElementById("statInfo").innerHTML = result;
}
}
}
页面
<form ....>
...
<div id="statInfo" style="width:1150px; height:480px; overflow:scroll; font-size:smaller"></div>
...
</form>
注:没有form标签的时候好用
var xmlHttpReq;
function createXMLHttpRequest() {
if (xmlHttpReq == null) {
if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
} else {
xmlHttpReq = new XMLHttpRequest();
}
}
}
function sendReq(Model) {
document.getElementById("SearchStation").value = Station;
createXMLHttpRequest();
var sendTime = new Date();
var url = "servlet/getStationInfo?Model=" + Model;
xmlHttpReq.open("GET", url, true);
xmlHttpReq.onreadystatechange = showResult;
xmlHttpReq.send();
}
function showResult() {
if (xmlHttpReq.readyState == 4) {
if (xmlHttpReq.status == 200) {
var result = xmlHttpReq.responseText;
alert(result);
document.getElementById("statInfo").innerHTML = result;
}
}
}
页面
<form ....>
...
<div id="statInfo" style="width:1150px; height:480px; overflow:scroll; font-size:smaller"></div>
...
</form>
注:没有form标签的时候好用
作者: garyfire 发布时间: 2011-01-22
跟form没有关系,请贴出全部的代码
作者: net_lover 发布时间: 2011-01-22
知道原因了,我取回来的数据里面也有form,去掉就正常了
作者: garyfire 发布时间: 2011-01-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28