实现无刷新加载数据(asp+ajax)


<div id="newphotos">数据载入中……</div>

<script language="JavaScript">

function getXML(URL){

if (window.XMLHttpRequest) { var xmlhttp = new XMLHttpRequest();

} else { var MSXML = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']; for(var n = 0; n < MSXML.length; n ++) { try { var xmlhttp = new ActiveXObject(MSXML[n]); break; } catch(e) { } } } xmlhttp.Open("GET", URL, false); try{ xmlhttp.Send(); var result = xmlhttp.status; } catch(e){ return(false); } if(result==200){ newphotos.innerHTML=unescape(xmlhttp.responseText); } var xmlhttp = null; }

function update(){ getXML('ajaxserver/newphoto.asp?placeid=<%= placeid %>&placecityid<%= placecityid %>'); }

setInterval("update()",1000);

</script>

asp文件

newphoto.asp

<!--#include file="include.asp" --> <% placeid=Request("placeid") placecityid=Request("placecityid")

xmlhttp="" xmlhttp=xmlhttp&"<table width=""99%"" height=""149"" border=""0"" align=""right"" cellpadding=""3"" cellspacing=""0"" class=""fuangkuanghs"">"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&"<td valign=""top""><table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&"<td height=""20"" align=""left"" class=""textblue""><table width=""396"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&" <td width=""65%""><a href="" src=""images/index/index_01.jpg"" width=""349"" height=""23"" border=""0""></a></td>"&chr(13) xmlhttp=xmlhttp&"<td width=""35%""><a href=""http://www.jiluyisheng.com/photo.asp?placeid="&placeid&"&placecityid="&placecityid&""" target=""_self""><img src=""images/index/index_02.jpg"" width=""47"" height=""23"" border=""0""></a></td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"</table>"&chr(13) xmlhttp=xmlhttp&"</td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&"<td valign=""top""><table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) set rs=userconn.execute("select top 3 weburl,photo_name,Photo_smallimg,idx_photo,jiuid,hits from v_jiphoto where weburl<>'' and iflag=2 and priv=1 "&where_str&" order by idx_photo desc") 'set rs=userconn.execute("select top 5 * from jiphoto where weburl<>'' and systype=5 order by idx_photo desc") if not rs.eof then

do while not rs.eof weburl=rs("weburl") if weburl<>"" then web= Replace(weburl,"http://","") picurl=weburl&"/Uploadfile/"&web& "/Photo/smallimg/" & rs("Photo_smallimg") else picurl="images/h3.gif" end if xmlhttp=xmlhttp&"<td height=""25"" align=""center""><table width=""99%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&"<td height=""12"" align=""center""><table width=""123"" height=""93"" border=""1"" cellpadding=""3"" cellspacing=""0"" bordercolor=""#cccccc"" style=""BORDER-COLLAPSE: collapse"">"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&"<td width=""123"" height=""93"" align=""center""><a target=blank href="&weburl&"/photo.asp?idx_photo="&rs("idx_photo")&"&jiuid="&rs("jiuid")&"><img src="&picurl&" οnlοad=""javascript:DrawImage(this,115,67)"" alt=""点击看大图"" width=""115"" height=""67"" border=""0""/></a> </td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"</table>"&chr(13) xmlhttp=xmlhttp&"</td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"<tr>"&chr(13) xmlhttp=xmlhttp&"<td height=""12"" align=""center"">"&FilterString(Rs("photo_name"),9)&"("& Rs("hits")&"/"&P.Get_RsCount(userconn,"[JiPhoto_reply]","idx_Photo="&rs("idx_photo"))&")</td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"</table></td>"&chr(13) Rs.MoveNext loop end if rs.close() set rs=nothing xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"</table></td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"</table></td>"&chr(13) xmlhttp=xmlhttp&"</tr>"&chr(13) xmlhttp=xmlhttp&"</table>"&chr(13) Response.write(escape(xmlhttp)) %>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值