解决 ajax返回乱码[JS]

一般不用VB脚本,所以发个JS的

调用 bd= gb2utf8(XMLHttp.ResponseBody);

function gb2utf8(data){
var glbEncode = [];
gb2utf8_data = data;
execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
var t=escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
t=t.split("@");
var i=0,j=t.length,k;
while(++i<j) {
k=t.substring(0,4);
if(!glbEncode[k]) {
gb2utf8_char = eval("0x"+k);
execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
glbEncode[k]=escape(gb2utf8_char).substring(1,6);
}
t=glbEncode[k]+t.substring(4);
}
gb2utf8_data = gb2utf8_char = null;
return unescape(t.join("%"));
}

你可能感兴趣的:(Ajax,function,脚本,VBScript,vb)