JS调用ASP动态数据显示

chen991 2007-06-12 11:19:27
一个ASP文件 top10.asp

<%
sql = "select top 10 * from news "
rs.open sql,conn,1,1
while not rs.eof
response.write rs("caption")&"<br>"
rs.movenext
wend
rs.close
%>

index.htm
在该页面里面要显示出top10.asp 的数据
我用这种方式调用
<script language="javascript" src="top10.asp"></script>

但在index.htm页面中不显示数据

请教各位大虾,这种方法是不能实现吗?要这样实现有什么其他的方法
...全文
575 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
blankfang 2007-06-12
  • 打赏
  • 举报
回复
看看一些字符方面有错误吗》》
做这个东西要仔细!!!
chen991 2007-06-12
  • 打赏
  • 举报
回复
各位帮帮忙啊,在线等待!
mylijie 2007-06-12
  • 打赏
  • 举报
回复
还有,好像不用加<script language="javascript"></script>
mylijie 2007-06-12
  • 打赏
  • 举报
回复
同意小良,但要注意特殊字符
chen991 2007-06-12
  • 打赏
  • 举报
回复
<!--#include file="top10.asp" -->
试过了,还是不行
chen991 2007-06-12
  • 打赏
  • 举报
回复
把top10.asp改在下面的形式也不能显示数据
<script language="javascript">
<%
sql = " select top 10 * from t_news"
rs.open sql,conn,1,1
while not rs.eof
%>
document.write ("<%=rs("caption")%>"+"<br>");
<%
rs.movenext
wend
rs.close
%>
</script>
ice241018 2007-06-12
  • 打赏
  • 举报
回复
这样试试
<!--#include file="top10.asp" -->
chen991 2007-06-12
  • 打赏
  • 举报
回复
谢谢 Wisgafe()

按你的方法可以了。
Wisgafe 2007-06-12
  • 打赏
  • 举报
回复
document.write ("<%=rs("caption")%>"+"<br/>");
上面这句改成 Response.write("document.write ('"&rs("caption")&"<br/>');")
bluelazyboy 2007-06-12
  • 打赏
  • 举报
回复
top10.asp document.write()
purplecalm 2007-06-12
  • 打赏
  • 举报
回复
I think you should know how to deal with the response content.


if you still have problems, send mail to me: purple.calm@gmail.com
purplecalm 2007-06-12
  • 打赏
  • 举报
回复
you can use Ajax. for example

//javascript
var xml_list;
var get_top_list=function(){
if(window.XMLHttpRequest){
xml_list=new XMLHttpRequest();
}else if(typeof ActiveXObject != "undefined"){
xml_list=new ActiveXObject("Microsoft.XMLHTTP");
}

xml_list.open("GET","top10.asp",true);

xml_list.onreadystatechange=_top_list_state;

xml_list.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

xml_list.send(null);

}

var _top_list_state=function(){

if(xml_list.readyState==4){

//show the response content, the responseText is all of the content you should use.
alert(xml_list.responseText);
}
}
e8soft 2007-06-12
  • 打赏
  • 举报
回复
在静态页中要用document.write()
e8soft 2007-06-12
  • 打赏
  • 举报
回复
用<iframe> 在TOP10.asp 中REFLASH=5 定时刷新吧。

或用AJAX
blackfire1024 2007-06-12
  • 打赏
  • 举报
回复
大哥 这是vbscript 怎么能用javascript包含呢

而且这是服务端脚本 要加上 runat=server

如果要动态的调用

必须用AJAX了

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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