在jsp页面中使用ajax来无刷新更新页面遇到的问题 补充下,程序执行到 $("#my").html(data);页面就变空白。 data是有数据的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 data是什么数据,打出来看下。 data数据:<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"--> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>分页显示</title> <SCRIPT type="text/javascript" src="./js/jquery.min.js" ></SCRIPT> </head> <body bgcolor="#ffffff" text="#000000"> <script type="text/javascript"> $(function(){ function showData(pageNo){ var actionUrl="./SplitePages.jsp"; //点击左边调用后台的url $.ajax({ url : actionUrl , dataType:"html", data:{showPadge:pageNo}, beforeSend :function(xmlHttp){ // deforeSend 是请求前清除缓存 ,如果没有缓存也不使用beforeSend //alert("before"); //xmlHttp.setRequestHeader("If-Modified-Since","0"); //xmlHttp.setRequestHeader("Cache-Control","no-cache"); } , success : function(data) { //data 是返回的数据 alert(data.length); //$("body").html(data); // id books 是右边的一个显示图书列表的 div $("#my").text(data); //alert($("#myD").text()); } , error: function(xml){ alert("daf"); }, }); } $(".pageNo").click(function(e){ e.preventDefault();//阻止跳转 showData($(this).text()); }); }); </script> <h1 id="h1" align=center>个人基本信息</h1> <div align=center> <table border="1" cellspacing="0" cellpadding="0" width="80%"> <tr> <th width="20%">编号</th> <th width="40%">学号</th> <th width="40%">姓名</th> </tr> <tr> <td>01001001</td> <td>毛呢外套</td> </tr> <tr> <td>01001002</td> <td>羽绒服</td> </tr> <tr> <td>01001003</td> <td>针织衫</td> </tr> <tr> <td>01001004</td> <td>棉衣</td> </tr> <tr> <td>01001005</td> <td>皮草</td> </tr> <tr> <td>01001006</td> <td>T恤</td> </tr> <tr> <td>01001007</td> <td>衬衫</td> </tr> <tr> <td>01001008</td> <td>真皮皮衣</td> </tr> <tr> <td>01001009</td> <td>羊绒衫</td> </tr> <tr> <td>01001010</td> <td>卫衣</td> </tr> </table> <p>共<font color=red>125</font>条 10条/页 第<font color=red>1</font>页/共<font color=red>13</font>页 [<a href="SplitePages.jsp?showPage=1" target="_self">首页</a>] <a class="pageNo" href="SplitePages.jsp?showPage=2" target="_self"><font color=red >2</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=3" target="_self"><font color=red >3</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=4" target="_self"><font color=red >4</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=5" target="_self"><font color=red >5</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=6" target="_self"><font color=red >6</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=7" target="_self"><font color=red >7</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=8" target="_self"><font color=red >8</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=9" target="_self"><font color=red >9</font></a> <a class="pageNo" href="SplitePages.jsp?showPage=10" target="_self"><font color=red >10</font></a> </div> <div id="my"></div> </body> </html> 解决了,是引用了jquery引起的。谢谢。各位了。 javascript 如何获取 display 的值? offsetWidth的浏览器兼容问题。 javascript中的var setTimeout 问题 请问下: JQuery-UI 和ASP.Net的服务器端控件的问题 求助,关于vml实现3d的问题 请问用javascript如何实现求两个日期相隔的天数 window.open怎样把打开窗口设置为最大化? js和javascript的困惑~~~~ 简单问题,20分!请大家帮忙。。 如何用javascript获取页面ID值 关于jqGrid reload的问题
data数据:
<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>分页显示</title>
<SCRIPT type="text/javascript" src="./js/jquery.min.js" ></SCRIPT>
</head>
<body bgcolor="#ffffff" text="#000000">
<script type="text/javascript">
$(function(){
function showData(pageNo){
var actionUrl="./SplitePages.jsp"; //点击左边调用后台的url
$.ajax({
url : actionUrl ,
dataType:"html",
data:{showPadge:pageNo},
beforeSend :function(xmlHttp){ // deforeSend 是请求前清除缓存 ,如果没有缓存也不使用beforeSend
//alert("before");
//xmlHttp.setRequestHeader("If-Modified-Since","0");
//xmlHttp.setRequestHeader("Cache-Control","no-cache");
} ,
success : function(data) { //data 是返回的数据
alert(data.length);
//$("body").html(data); // id books 是右边的一个显示图书列表的 div
$("#my").text(data);
//alert($("#myD").text());
} ,
error: function(xml){
alert("daf");
},
});
}
$(".pageNo").click(function(e){
e.preventDefault();//阻止跳转
showData($(this).text());
});
});
</script>
<h1 id="h1" align=center>个人基本信息</h1>
<div align=center>
<table border="1" cellspacing="0" cellpadding="0" width="80%">
<tr> <th width="20%">编号</th>
<th width="40%">学号</th>
<th width="40%">姓名</th>
</tr>
<tr> <td>01001001</td>
<td>毛呢外套</td>
</tr>
<tr> <td>01001002</td>
<td>羽绒服</td>
</tr>
<tr> <td>01001003</td>
<td>针织衫</td>
</tr>
<tr> <td>01001004</td>
<td>棉衣</td>
</tr>
<tr> <td>01001005</td>
<td>皮草</td>
</tr>
<tr> <td>01001006</td>
<td>T恤</td>
</tr>
<tr> <td>01001007</td>
<td>衬衫</td>
</tr>
<tr> <td>01001008</td>
<td>真皮皮衣</td>
</tr>
<tr> <td>01001009</td>
<td>羊绒衫</td>
</tr>
<tr> <td>01001010</td>
<td>卫衣</td>
</tr>
</table>
<p>共<font color=red>125</font>条 10条/页
第<font color=red>1</font>页/共<font color=red>13</font>页
[<a href="SplitePages.jsp?showPage=1" target="_self">首页</a>]
<a class="pageNo" href="SplitePages.jsp?showPage=2" target="_self"><font color=red >2</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=3" target="_self"><font color=red >3</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=4" target="_self"><font color=red >4</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=5" target="_self"><font color=red >5</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=6" target="_self"><font color=red >6</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=7" target="_self"><font color=red >7</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=8" target="_self"><font color=red >8</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=9" target="_self"><font color=red >9</font></a>
<a class="pageNo" href="SplitePages.jsp?showPage=10" target="_self"><font color=red >10</font></a>
</div>
<div id="my"></div>
</body>
</html>