Ajax跨域代理访问网络资源的实现代码

2019-01-13 04:00:01于丽

}
return b;
};

_SmartHttp.prototype.getrnd = function (){return Math.random().toString().substr(2);};

_SmartHttp.prototype.b2s = function(bytSource, Cset){ //ef bb bf,c0 fd
var Objstream,c1,c2,c3;
var byts;
Objstream =Server.CreateObject("ADODB.Stream");
Objstream.Type = 1;
Objstream.Mode = 3;
Objstream.Open();
Objstream.Write(bytSource);
Objstream.Position = 0;
Objstream.Type = 2;
Objstream.CharSet = Cset;
byts = Objstream.ReadText();
Objstream.Close();
Objstream = null;
return byts;
};
_SmartHttp.prototype.urlencode=function(str){ return encodeURIComponent(str);};
_SmartHttp.prototype.urldecode=function(str){ return decodeURIComponent(str);};
String.prototype.trim = function(){return this.replace(/(^(s+)|(s+)$)/igm,"");};
</script>

使用代码:

<!--#include file="smart.asp"-->
<%
Response.charset="utf-8"
dim url,method,data,charset
url =Request.Form("targeturl")
method =Request.Form("method")
data =Request.Form("data")
charset = Request.Form("charset")
if charset = "" then charset = "GB2312"
response.Write SmartHttp(url,method,data).send().gettext(charset)
set myhttp = nothing
%>

代码打包下载

您可能感兴趣的文章:

Ajax 设置Access-Control-Allow-Origin实现跨域访问解决ajax不能访问本地文件问题(利用js跨域原理)AJax与Jsonp跨域访问问题小结Ajax实现跨域访问的三种方法JSONP跨域GET请求解决Ajax跨域访问问题浅谈Ajax跨域Session和跨域访问JQuery Ajax 跨域访问的解决方案解决AJAX中跨域访问出现''没有权限''的错误Ajax实现跨域访问最新解决方案