📄 xmlrpc.js
字号:
var xmlrpc = function()
{
var core = this;
var http = this.http = new XMLHttpRequest();
var data = [];
var head = [];
this.callBack = function(){};
this.doGet = function(strURL, async)
{
var _query = core.getData();
var _addr = strURL;
if (_query != "")
{
_addr += ((strURL.indexOf("?") != -1) ? "&" : "?") + _query;
}
http.open("GET", _addr, async);
for (var i = 0; i < head.length; i++)
{
http.setRequestHeader(head[i].name, head[i].value);
}
if (async == true)
{
http.onreadystatechange = core.callBack;
}
http.send(null);
};
this.doPost = function(strURL, async)
{
http.open("POST", strURL, async);
for (var i = 0; i < head.length; i++)
{
http.setRequestHeader(head[i].name, head[i].value);
}
if (async == true)
{
http.onreadystatechange = core.callBack;
}
var _data = core.getData();
if (typeof(_data) == "object")
{
http.setRequestHeader("CONTENT-TYPE", "text/xml");
}
else
{
http.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
}
http.send(_data);
};
this.setData = function(name, value)
{
data.push({"name": name, "value": value});
};
this.setHead = function(name, value)
{
head.push({"name": name, "value": value});
};
this.getData = function()
{
var ret = "";
for (var i = 0; i < data.length; i++)
{
if (typeof(data[i].value) == "object")
{
ret = data[i].value;
break;
}
else
{
if (ret != "") ret += "&";
ret += encodeURIComponent(data[i].name) + "=" + encodeURIComponent(data[i].value);
}
}
return(ret);
};
this.close = function()
{
delete http;
http = null;
};
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -