📄 ajax.js
字号:
var req = new function()
{
this.xhr = null;
this.xmldata = null; //xml数据
this.userid = null;
this.createInstance = function()
{
var instance = null;
try
{
instance = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
instance = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
instance = false;
}
}
if(!instance && typeof XMLHTTPRequest != 'undefined')
{
instance = new XMLHTTPRequest();
if (instance.overrideMimeType)
{
instance.overrideMimeType="text/xml";
}
}
return instance;
}
this.getxmldata= function()
{
this.userid = arguments[0];
xhr = this.createInstance();
xhr.onreadystatechange=this.buildxmltree;
xhr.open("GET","/getdatafromXML?userid="+arguments[0],true);
xhr.send(null);
}
this.buildxmltree = function() //构建tree
{
if(xhr.readyState==4)
{
if(xhr.status==200)
{
req.xmldata = xhr.responseText;
var o = new ActiveXObject('Microsoft.XMLDOM');
o.async = false;
o.loadXML(req.xmldata);
req.doXMLMsg(o);
}
else
{
//deal the error here
}
}
}
this.doXMLMsg = function(obj)
{//解释见treeview.js
treeview.data = obj;
treeview.xhr = req.xhr;
treeview.userid = req.userid;
treeview.init();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -