Ajax页面显示不正常
数据显示页面的代码:
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<head>
<%
String zdid=request.getParameter("zdid");
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<script language="javascript">
var XMLHttpReq;
//创建XMLHttpRequest对象
function createXMLHttpRequest() {
if(window.XMLHttpRequest) { //Mozilla 浏览器
XMLHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IE浏览器
try {
XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e){
try {
XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
}
//发送请求函数
function sendRequest() {
createXMLHttpRequest();
var url = "datafresh4?zdid=<%=zdid%>";
XMLHttpReq.open("GET", url, true);
XMLHttpReq.onreadystatechange = processResponse;//指定响应函数
XMLHttpReq.send(null); // 发送请求
}
// 处理返回信息函数
function processResponse() {
if (XMLHttpReq.readyState == 4) { // 判断对象状态
if (XMLHttpReq.status == 200) { // 信息已经成功返回,开始处理信息
DisplayHot();
setTimeout("sendRequest()", 1000);
} else { //页面不正常
window.alert("您所请求的页面有异常。");
}
}
}
function DisplayHot() {
var sanshashuiwen = XMLHttpReq.responseXML.getElementsByTagName("sanshashuiwen")[0]. firstChild.nodeValue;
var sanshaqixiang = XMLHttpReq.responseXML.getElementsByTagName("sanshaqixiang")[0]. firstChild.nodeValue;
document.getElementById("sanshashuiwen").innerHTML =sanshashuiwen;
document.getElementById("sanshaqixiang").innerHTML =sanshaqixiang;
}
</script>
<body onload =sendRequest() background="images/bg.gif" >
<p class="InTimeData">
<table width="1024" border="0" height="29">
<tr height="100%">
<div id="sanshashuiwen" style="position:absolute; width:195px; height:87px; z-index:1; left: 59px; top: 60px;" ></div>
<div id="sanshaqixiang" style="position:absolute; width:240px; height:142px; z-index:1; left: 263px; top: 60px;" ></div> </td>
</tr>
</table>
</center>
</body>
</html>
datafresh4?zdid=400是可以正常显示的
显示的内容:
- <response>
<sanshashuiwen>没有数据。</sanshashuiwen>
<sanshaqixiang><font color=#71626C>站点ID:</font><font color=#000000>400.0</font><br>
<font color=#71626C>温度:</font><font color=#000000>15.3</font><br>
<font color=#71626C>湿度:</font><font color=#000000>51.6</font><br>
<font color=#71626C>气压:</font><font color=#000000>1020.5</font><br>
<font color=#71626C>降水:</font><font color=#000000>0.0</font><br>
<font color=#71626C>能见度:</font><font color=#000000>0.0</font><br>
<font color=#71626C>风速:</font><font color=#000000>6.36</font><br>
<font color=#71626C>风向:</font><font color=#000000>58.0</font><br>
</sanshaqixiang>
</response>
可是数据显示页面运行是一直提示:您请求的页面有异常,大家帮我看看错误出在哪了?我想查看具体的错误信息,不知道该怎么看,怎么把具体的错误信息打印出来呢?用out.println(e.toString())放在js中似乎不行,大家帮帮忙吧,十分感谢!