asp如何在html调用

chuans 2010-12-29 06:48:27
<%
Path="qq360"
t = GetBody(Path) '
Response.BinaryWrite t '

Function GetBody(url) '
Set Retrieval = CreateObject("Microsoft.XMLHTTP") '
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetBody = .ResponseBody '函数返回获取的内容
End With
on error resume next
if Retrieval.status<>200 then
Set Retrieval = Nothing
exit function
end if
End Function
%>

这段代码怎么改成能让html 执行?用JS也行的。谢谢
...全文
226 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
chuans 2010-12-31
  • 打赏
  • 举报
回复
help
chuans 2010-12-31
  • 打赏
  • 举报
回复
在线等待。。
chuans 2010-12-31
  • 打赏
  • 举报
回复
不行啊。。。
chuans 2010-12-30
  • 打赏
  • 举报
回复
还在吗??
Forthleo 2010-12-30
  • 打赏
  • 举报
回复
这几种方法都行的:

asp代码保存为a.asp

1:JS调用
<script src="a.asp" ></script>
2:图片调用
<img src="a.asp" width=1 height=1>
3:IFRAME调用
<iframe src="a.asp" width=1 height=1>
chuans 2010-12-30
  • 打赏
  • 举报
回复
help...
meichen8050753 2010-12-30
  • 打赏
  • 举报
回复
<script src="xxx.asp" ></script>
chuans 2010-12-30
  • 打赏
  • 举报
回复
是在其他站获取信息。。是读取了 再在本地保存输出的。。wangluonanhai 你的代码 读取的地址在哪里改啊?
Atai-Lu 2010-12-30
  • 打赏
  • 举报
回复
你是要得到本站的信息还是别的网站上的信息?
如果是本站上的信息,上面的几个答案都不错

如果是其他网站上的信息,用js实现很麻烦,有个跨域的问题比较难解决。
网络老男孩了 2010-12-30
  • 打赏
  • 举报
回复
<%@ page pageEncoding="UTF-8"%>
<html>
<head>
<title>Ajax</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
var okFunc = function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
$("#msg").html(xmlHttp.responseText);
}
}
}
var startAjax = function(){
$("#msg").html("Loading...");
createXMLHttpRequest();
if( !xmlHttp){
return alert('create failed');
}
xmlHttp.open("POST", "Test", true);
xmlHttp.onreadystatechange = okFunc;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(document);
}
$(document).ready(function(){
$("#start").click(startAjax);
$.post("Test",{'name':'Hello','age':22});
});
</script>
<head>

<body>
Ajax.jsp<br/>
<div id="msg" style="background-color:#EEEEEE;width:400px;height:200px;margin:1em;padding:1em;border:1px solid #DD6900">
啦啦啦
</div>
<button id="start" style="margin:1em;border:1px solid #DD6900">Start Ajaxbutton
</body>
</html>
xiexiaokang 2010-12-30
  • 打赏
  • 举报
回复
你直接写成js,然后在html里调用js就可以,百度一下,例子很多
网络老男孩了 2010-12-30
  • 打赏
  • 举报
回复
啊,我写的就是js调用xmlhttp控件的啊.
<%
Path="qq360"
t = GetBody(Path) '
Response.BinaryWrite t '

Function GetBody(url) '
Set Retrieval = CreateObject("Microsoft.XMLHTTP") '
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetBody = .ResponseBody '函数返回获取的内容
End With
on error resume next
if Retrieval.status<>200 then
Set Retrieval = Nothing
exit function
end if
End Function
%>

你这段是asp调用xmlhttp啊

<script>
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
var okFunc = function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
$("#msg").html(xmlHttp.responseText);
}
}
}
var startAjax = function(){
$("#msg").html("Loading...");
createXMLHttpRequest();
if( !xmlHttp){
return alert('create failed');
}
xmlHttp.open("POST", "Test", true);
xmlHttp.onreadystatechange = okFunc;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(document);
}
$(document).ready(function(){
$("#start").click(startAjax);
$.post("Test",{'name':'Hello','age':22});
});
</script>
我写的就是js调用xmlhttp
chuans 2010-12-30
  • 打赏
  • 举报
回复
看不懂啊。。
网络老男孩了 2010-12-30
  • 打赏
  • 举报
回复
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
var okFunc = function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
$("#msg").html(xmlHttp.responseText);
}
}
}
var startAjax = function(){
$("#msg").html("Loading...");
createXMLHttpRequest();
if( !xmlHttp){
return alert('create failed');
}
xmlHttp.open("POST", "Test", true);
xmlHttp.onreadystatechange = okFunc;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(document);
}
$(document).ready(function(){
$("#start").click(startAjax);
$.post("Test",{'name':'Hello','age':22});
});

网络老男孩了 2010-12-30
  • 打赏
  • 举报
回复
http://approach.javaeye.com/blog/125407
chuans 2010-12-30
  • 打赏
  • 举报
回复
大牛 帮忙。。
chuans 2010-12-30
  • 打赏
  • 举报
回复
运行了没反应哦;。
chuans 2010-12-30
  • 打赏
  • 举报
回复
有人给了我个代码。为什么我运行了 没反应啊?
用ajax就行了啊,
html文件为:1.html
asp文件为:1.asp
以下是jQuery的:
<script type="text/javascript">
$(function(){
$.ajax({
type:'POST',
url:'1.asp',
data:'var=dddd&val=1111',
success:function(returnValue){
alert(returnValue);
}
})
});
</script>
xiexiaokang 2010-12-30
  • 打赏
  • 举报
回复
1:JS调用
<script src="a.asp" ></script>
2:图片调用
<img src="a.asp" width=1 height=1>
3:IFRAME调用
<iframe src="a.asp" width=1 height=1>
qq85168163 2010-12-30
  • 打赏
  • 举报
回复
用ajax
加载更多回复(8)

28,390

社区成员

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

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