日期:2014-05-17 浏览次数:20724 次
<script type="text/javascript"> var ajaxConn; function createHttpRequest() { try { if(window.XMLHttpRequest) { ajaxConn=new XMLHttpRequest(); } else if(window.ActiveXObject) { ajaxConn=new ActiveXObject("Msxml2.XMLHTTP"); } } catch(e) { ajaxConn=new ActiveXObject("Microsoft.XMLHTTP"); } } function disData() { createHttpRequest(); var url="test.do"; ajaxConn.open("POST",url,true); ajaxConn.onreadystatechange=handleResult; ajaxConn.send(""); } function handleResult() { if(ajaxConn.readyState==4) { if(ajaxConn.status==200) { var tt=document.getElementById("t"); //tt.innerHTML=tt.value+"\n"+ajaxConn.responseText;//注意这样好像不能换行 tt.value=tt.value+"\n"+ajaxConn.responseText;//这样可以换行 setTimeout("disData()",1000); } else { alert("出错"); } } } </script>
<button onclick="disData()">点我测试</button> <textarea id="t" name="t" rows="6" cols="45" ></textarea>
out.println("testing ....");