Ajax+jquery在首页显示新闻遇到加载问题??

Magiccrystal 2010-02-08 11:24:25
我在首页用ajax显示前五条新闻:这是我在:
<script type="text/javascript">
function showinfo(){
var pdata =document.getElementById("newInfo").innerHTML;
$.ajax({
type:"POST",
url:"${ctx}/message/message!showinfo.action",
data:pdata,
success:function (data){
document.getElementById("newInfo").innerHTML=data;
},
error:function (data){
alert("没有访问的信息!");
}
});
}
</script>

在index.jsp中:我显示消息的那个小块:<td height="174">
<div id="newInfo">
<table border="0" height="112" align="center" cellpadding="0" cellspacing="0" bgcolor="#666666" id="listTable">
<tr>
<td width="254" height="18" bgcolor="#FFFFFF" class="STYLE18">NEWS</td>
<td width="89" height="18" bgcolor="#FFFFFF">
<div align="right"><a href="news-center.html">
<img src="images/more.jpg" width="46" height="15" border="0"/></a>
</div>
</td>
</tr>
<s:iterator value="page.result">
<tr>
<td height="18" bgcolor="#FFFFFF"><p align="left" class="STYLE33">
<a href="news2009-11-06.html" class="STYLE24 STYLE32" style=" text-decoration:none">${title}</a></p>
</td>
<td bgcolor="#FFFFFF"><span class="STYLE20">  
<span class="STYLE23"> ${createDate}</span></span>
</td>
</tr>
</s:iterator>
</table></div>
然后在消息Action中:
@Results( { @Result(name = "reload", location = "message!list.action", type = "redirect") })
public class MessageAction extends ActionSupport {

// 分页显示消息
public String list() throws Exception {

page = messageManager.pager(page);
catalogs = messageManager.getCatalogTypeAll();
return "list";
}

public String showinfo() throws Exception {
page = messageManager.pager(page);
catalogs = messageManager.getCatalogTypeAll();
return "reload";
}
但是以上做的达不到效果,在index.jsp中没有显示新闻,我该怎么改这一块,达到效果啊??希望各位帮我了谢谢,我现在很急,对ajax不是很熟,非常感谢!!!!
...全文
206 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Magiccrystal 2010-02-25
  • 打赏
  • 举报
回复
问题,解决了,谢谢了
Magiccrystal 2010-02-20
  • 打赏
  • 举报
回复
<div id="content">
<div id="content_right">
<table width="915" height="225" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" background="${ctx}/images/news.jpg" height="50px">                                  <span
class="STYLE14"><a href="${ctx}/html/news-center.jsp" style="color:#000000; text-decoration:none">佰冠的优惠及新闻请点击查看</a></span>
</td>
</tr>
<tr>
<td height="174">
<div id="newInfo">
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#666666" id="listTable">
<tr>
<td width="254" height="18" bgcolor="#FFFFFF" class="STYLE18">NEWS</td>
<td width="89" height="18" bgcolor="#FFFFFF">
<div align="right"><a href="news-center.html">
<img src="${ctx}/images/more.jpg" width="46" height="15" border="0"/></a>
</div>
</td>
</tr>
<s:iterator value="page.result">
<tr>
<td height="18" bgcolor="#FFFFFF"><p align="left" class="STYLE33">
<a href="news"+${createDate}+".html" class="STYLE24 STYLE32" style=" text-decoration:none">${title}</a></p>
</td><td bgcolor="#FFFFFF"><span class="STYLE20">  
<span class="STYLE23">${createDate}</span></span>
</td>
</tr>
</s:iterator>
</table>
</div>
</td>
<td width="286">
<div align="right"><a href="http://www.baiguan.info/register">
<img src="${ctx}/images/free.jpg" width="255" height="170" border="0" align="top"/></a>
</div>
</td>
<td width="286">
<div align="left"><a href="http://www.baiguan.info/welcome.jsp">
<img src="${ctx}/images/enter.jpg" width="255" height="170" border="0"/></a></div>
</td>
</tr>
</table>
</div>
</div>

<div id="copyright">
<table width="950" height="100" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="19" colspan="4"> </td>
</tr>
<tr height="45">
<td width="140"><a href="${ctx}/message/message!list.action">测试我的消息模块功能</a> </td>
<td height="19" colspan="2" class="STYLE4"><p align="center" class="STYLE10 STYLE12">           Microsoft
Internet Explorer 7.0              Best
Resolution ratio 1024*768 </span>              粤ICP备a53866875
<br/>
<span class="STYLE11"></span></p>

<p align="center" class="STYLE10 STYLE12">          Copyright
© 2009 ShenZhen BAIGUAN Infomation consultant Co.Ltd All rights Reserved</p>

<p align="left" class="STYLE10"> </p></td>
<td width="212" class="STYLE4"> </td>
</tr>
</table>
</div>

以上的<div id="copyright">部分没有了,我该怎么改???
Magiccrystal 2010-02-20
  • 打赏
  • 举报
回复
我现在把显示的部分MessageAction中的方法:
public void showinfo() throws Exception {
page = messageManager.pager(page);
StringBuilder html = new StringBuilder();
for (Message message : page.getResult()) {
html.append(" <td height='18' bgcolor='#FFFFFF'><p align='left' class='STYLE33'>"+ "<a href='news2009-11-06.html' class='STYLE24 STYLE32' style=' text-decoration:none'>"+ message.getTitle() + "</a></p>" + "</td>"+ "<td bgcolor='#FFFFFF'><span class='STYLE20'>  "+ "<span class='STYLE23'> " + message.getCreateDate()+ "</span></span>" + "</td>");
}
Struts2Utils.renderHtml(html.toString());
//catalogs = messageManager.getCatalogTypeAll();
return;

}
页面的新闻显示了,但是后面排版的都没有,是不是用到了StringBuilder造成的,我现在在首页该怎么做,好烦实现不了?各位高手帮帮我,谢谢了啊
Pig23 2010-02-10
  • 打赏
  • 举报
回复
排版问题吧,先把版面调整好了再加上ajax代码
Magiccrystal 2010-02-10
  • 打赏
  • 举报
回复
显示后但是把后面版权区 挡住了,也就是版权区显示不了,怎么改正???
unicode 2010-02-10
  • 打赏
  • 举报
回复
你直接把后台的那段html代码放到newinfo的位置能显示吗?如果不能那就是你的html代码有问题

52,797

社区成员

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

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