国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

Ajax跨域代理訪問網(wǎng)絡(luò)資源的實現(xiàn)代碼

2024-05-04 10:59:55
字體:
供稿:網(wǎng)友
smart.asp
復(fù)制代碼 代碼如下:
<script language="jscript" runat="server">
/*
在VBS里面的調(diào)用方法
dim myhttp
set myhttp = SmartHttp(url,method,data); //三個參數(shù)均可選
屬性:
url:String,請求的URL地址
method:String,請求的方法
data:String,請求的數(shù)據(jù)
charset:String,請求的URL返回數(shù)據(jù)的編碼
status:Int,請求返回的狀態(tài)碼
readyState:Int,同HTTP請求的當(dāng)前通訊狀態(tài),1、2、3、4
dataset:Object,請求的數(shù)據(jù),如果增加了,會將這部分?jǐn)?shù)據(jù)附加到data屬性
dataset屬性:
charset:String,發(fā)送數(shù)據(jù)的編碼
dataset方法:
append(key,value,noencode):添加數(shù)據(jù)
remove(key):移除某個數(shù)據(jù)項
isexists(key):判斷某個數(shù)據(jù)項是不是存在
clear:清除所有數(shù)據(jù)項
方法:
header(headstr):設(shè)置請求頭,項和值之間用:分開
timeout(t1,t2,t3,t4):設(shè)置超時時間
send():發(fā)送請求
getbinary:獲取服務(wù)器返回的二進制數(shù)據(jù)
gettext(charset):獲取指定編碼的文本
getjson(charset):獲取指定編碼的json數(shù)據(jù)
getheader(key):獲取服務(wù)器返回的響應(yīng)頭
getxml(charset):獲取指定編碼的xml數(shù)據(jù)
*/
function SmartHttp(url,method,data){
return new _SmartHttp(url,method,data);
}

function _SmartHttp(url,method,data){
if(typeof method=="undefined") method="GET";
if(typeof data=="undefined") data="";
method = method.toUpperCase();
method = method!="POST" ? "GET" : "POST";
this.timeout=[10000,10000,10000,10000];
this.method = method;
this.url=url;
this.data=data;
this.charset="gb2312";
this.http=null;
this.headers=[];
this.status=0;
this.readyState=0;
this.content=null;
this.msg="";
this.dataset={
charset:"gb2312",
data:[],
append:function(key,value,noencode){
var fn=null;
if(this.charset.toLowerCase()=="utf-8"){fn = encodeURIComponent;}else{fn = escape;}
if(noencode==true){fn=function(_str){return _str;}}
this.data.push({"key":fn(key),"value":fn(value)});
},
remove:function(key){
if(this.data.length<=0) return false;
var _data=[];
for(var i=0;i<this.data.length;i++){
if(this.data[i].key!=key){
_data.push(this.data[i]);
}
}
this.data = _data;
},
isexists:function(key){
if(this.data.length<=0) return false;
for(var i=0;i<this.data.length;i++){
if(this.data[i].key==key){
return true;
}
}
return false;
},
clear:function(){
this.dataset.data=[];
}
};
}

_SmartHttp.prototype.init=function(){
var datasetstr="";
if(this.dataset.data.length>0){
for(var i=0;i<this.dataset.data.length;i++){
datasetstr += this.dataset.data[i].key + "=" + this.dataset.data[i].value + "&";
}
}
if(datasetstr!="") datasetstr = datasetstr.substr(0,datasetstr.length-1);
if(this.data==""){this.data = datasetstr;}else{if(datasetstr!="")this.data+= "&" + datasetstr;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 达尔| 余姚市| 泾源县| 牟定县| 皋兰县| 镇原县| 稻城县| 镇巴县| 广宗县| 金坛市| 蒲江县| 蒙城县| 格尔木市| 平舆县| 砚山县| 滁州市| 中方县| 凤阳县| 惠来县| 民权县| 景洪市| 金昌市| 五大连池市| 和硕县| 鱼台县| 三河市| 西华县| 清新县| 泸西县| 德江县| 宣恩县| 饶平县| 嵊泗县| 南开区| 资中县| 石楼县| 含山县| 景德镇市| 桂阳县| 阜新| 县级市|