日期:2014-05-16 浏览次数:20688 次
var xhr=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("microsoft.xmlhttp"); xhr.open("get","xxxx.do?_dc="+new Date().getTime(),true); xhr.onreadystatechange=function(){ if(xhr.readyState==4){ if(xhr.status==200)alert(xhr.responseText); else alert(xhr.status+'\n\n'+xhr.responseText); } } xhr.send(null);
------解决方案--------------------
http://download.csdn.net/source/2256659
这里有个demo
------解决方案--------------------
//本代码用的是prototype框架实现,在IE中测试通过
//首先要引入prototype.js
<script type="text/javascript" src="../js/prototype.js" ></script>
//在JS中执行如下代码
function test(){
var http = new ActiveXObject("Msxml2.XMLHTTP");//生成一个XMLHTTP对象
var url = "/checkAction.do";//调用的action
http.open("GET", url, false);
http.send(); //发送请求
var msg = http.responseText;
alert(msg); //返回值
}
//action中的重要代码如下:
HttpServletResponse response = context.getResponse();
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.print("Test String!"); //将信息写入response