📄 ajax.js
字号:
var http_request = false;
function get_request() {//初始化、指定处理函数、发送请求的函数
http_request = false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest) { //Mozilla 浏览器
http_request = new XMLHttpRequest();
if(http_request.overrideMimeType) {//设置MiME类别
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) { // IE浏览器
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if(!http_request) { // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
else{
return http_request;
}
}
function selectRequests(xmlHttp,reqURL,showContent) {
xmlHttp.open('GET',reqURL,'true');
xmlHttp.onreadystatechange = function handleStateChange(){
if(xmlHttp.readyState == 2) {
document.getElementById(showContent).innerHTML = "正在载入......";
}
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
var outStringArray = xmlHttp.responseText.split(";");
var select_root=document.getElementById(showContent);
select_root.options.length=0;
var option=new Option("--请选择--","");
select_root.add(option);
for(var i=0;i<outStringArray.length-1;i++)
{
if(outStringArray[i]!=""){
var tmp=outStringArray[i].split(",");
var option=new Option(tmp[1],tmp[0]);
try{
select_root.add(option);
}catch(e){}
}
}
}
}
};
xmlHttp.send(null);
}
function startRequest(xmlHttp,reqURL,showContent) {
xmlHttp.open('GET',reqURL,'true');
xmlHttp.onreadystatechange = function handleStateChange(){
if(xmlHttp.readyState == 2) {
document.getElementById(showContent).innerHTML = "正在载入......";
}
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
var allcon = Bin2Str(xmlHttp.responseBody);
document.getElementById(showContent).innerHTML = allcon;
}
}
};
xmlHttp.send(null);
}
function show(c_Str){
if(document.all(c_Str).style.display=='none'){
document.all(c_Str).style.display='block'
}else{
document.all(c_Str).style.display='none'
}
}
function Bin2Str(Binary){
try{
var axRs = new ActiveXObject('ADODB.RecordSet');
axRs.Fields.Append('Binary2String',201,1);
axRs.open();
axRs.addNew();
axRs(0).appendChunk(Binary);
axRs.update();
var Result = axRs(0).value;
axRs.Close();
return Result;
}catch(e){
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -