ajax局部刷新为什么出不来效果?请大家指教

YAVA_2009 2012-03-29 09:13:28
<html>
<script language="javascript">

function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
var url="/test/test.jsp";
url=url+"&t="+Math.random();

xmlhttp.open("GET",url,true);
xmlhttp.send();//发送请求
}

</script>
<body>

<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">通过 AJAX 改变内容</button>
<div id="myDiv"></div>

</body>
</html>
...全文
128 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
小昭 2012-03-29
  • 打赏
  • 举报
回复
用firefox的firebug查看下网络那里,访问有没有成功,有没有返回数据什么的。。
Acesidonu 2012-03-29
  • 打赏
  • 举报
回复
<%
String name = request.getParameter("name");
%>
YAVA_2009 2012-03-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
用firefox的firebug查看下网络那里,访问有没有成功,有没有返回数据什么的。。
[/Quote]
thanks!
采用post方式,send方法传递拼装好的参数xmlHttp.send(str)
var url="CheckList.jsp";
xmlhttp.open("POST",url,true);
xmlhttp.send(str);//发送请求

在CheckList.jsp怎么去去这个值呢?初学,请多多指教

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧