代码如下 网上的方法都试过了
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="http://localhost:8080/test/">
<title>My JSP 'welcome2.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<SCRIPT LANGUAGE ="JavaScript">
function showInfo() {
var xmlHttp = new ActiveXObject("Msxml2.XMLTTTP");
xmlHttp.open("GET","index.jsp,ture");
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState == 4) {
infoDiv.innerHTML = xmlHTTP.responseText;
}
}
xmlHttp.send();
}
</SCRIPT>
欢迎来到本系统. <HR>
<input type = "button" value = "显示公司信息" onClick ="showInfo()">
<div id = "infoDiv"></div>
</body>
</html>
------解决方案--------------------
另外
var xmlHttp = new ActiveXObject("Msxml2.XMLTTTP");
改成
var xmlHttp =window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLTTTP");
对于高版本IE不再续改改设置了
------解决方案--------------------
var xmlHttp = new ActiveXObject("Msxml2.XMLTTTP");
----->上一句换成
var xmlHttp = null;
if (window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
}
else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest()
};