Ajax 图片显示的问题

dyengying 2009-03-31 06:11:38
<script language="javascript">
setInterval("ActivityLiveInfoService.getActiveRepit(activeCallBack)",5000);
activeCallBack = function(resultList){

var str ="<td>";
for(var i=0;i<resultList.length;i++){

var temObj = resultList[i];
str+="<tr>" + temObj.activity_live_content + "</tr>";
if(i == resultList.length -1)
{
var img = document.getElementById("activityImg");
img.src =temObj.activity_live_photo;
//temObj.activity_live_photo是从数据库中取得的图片链接地址,能不能这样用,能的话,应该怎么显示在页面上呢?页面代码在下面给出
}
}
str +="</td>";
var contentRefreshed = document.getElementById("contentRefreshed");
contentRefreshed.innerHTML =str;
}
</script>


页面代码
<tr>
<td width="155"> <img src="${activityLiveInfo.activity_live_photo}" border="0" width="140" heigh="120"> //想替换掉此句,高度宽度想保留
</td>
<td valign="top">

...全文
223 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
dnpyy 2009-03-31
  • 打赏
  • 举报
回复
可以给table、img赋个ID或NAME,直接用JS给它赋值.
dyengying 2009-03-31
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dnpyy 的回复:]
页面是这个样子,使用JSP做得吗?有没有用action?
[/Quote]
页面就是这个样子的
dnpyy 2009-03-31
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 dnpyy 的回复:]
错了,应该是有servlet
在servlet中用request.setAttribute("photolocation",photolocation);
这里photolocation指的是从数据库中提取出来的图片的地址。

在前台页面上
javascript脚本区:
红色区域改为str=request.getAttribute("photolocation");

<tr>
<td width="155"> <img src="${activityLiveInfo.activity_live_photo}" border="0" width="140" heigh="120">

红色区域改为src= <%=str%>
试试
[/Quote]



晕死了,把JavaScript当成是JSP了,应该是在页面上写JSP代码提取request.getAttribute("photolocation");
具体如下:
<%str = request.getAttribute("photolocation");%>
dyengying 2009-03-31
  • 打赏
  • 举报
回复
也没有servlet
dyengying 2009-03-31
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dnpyy 的回复:]
页面是这个样子,使用JSP做得吗?有没有用action?
[/Quote]
没有用action
dnpyy 2009-03-31
  • 打赏
  • 举报
回复
错了,应该是有servlet
在servlet中用request.setAttribute("photolocation",photolocation);
这里photolocation指的是从数据库中提取出来的图片的地址。

在前台页面上
javascript脚本区:
红色区域改为str=request.getAttribute("photolocation");

<tr>
<td width="155"> <img src="${activityLiveInfo.activity_live_photo}" border="0" width="140" heigh="120">

红色区域改为src=<%=str%>
试试
dnpyy 2009-03-31
  • 打赏
  • 举报
回复
页面是这个样子,使用JSP做得吗?有没有用action?

52,797

社区成员

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

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