这个函数是什么意思,请每句都解释一下
functionWebService(url,callback,method){try{vardivPlan=document.createElement("div");...
function WebService(url,callback,method)
{
try
{
var divPlan=document.createElement("div");
divPlan.innerHTML="<table width='100%' height='100%'><tr><td align='center' valign='middle'>读取数据中,请稍候……</td></tr></table>";
divPlan.style.styleFloat = "right";
divPlan.style.position= "absolute";
divPlan.style.margin = "auto";
divPlan.style.top = "10px";
divPlan.style.left = "10px";
divPlan.style.border = "1px solid #DDD";
divPlan.style.width = "200px";
divPlan.style.height = "30px";
divPlan.style.background = "#FFFFE0";
divPlan.style.filter = "alpha(opacity=90)";
divPlan.style.opacity = "0.90";
divPlan.style.zIndex = "999";
divPlan.style.display = "block";
document.body.appendChild(divPlan);
var xmldoc;
var webhttp = new WebObject(callback);
var index ;
var params = new Array;
var pn = 0;
var len = WebService.arguments.length;
for (var i=3; i < len; i++)
params[pn++] = WebService.arguments[i];
var cmd="WebObject_XML('" + method + "'";
for (var i=0; i < params.length; i++)
cmd += ",'" + escape(params[i]) + "'";
cmd += ")" ;
var xml=eval(cmd) ;
if(window.ActiveXObject)
{
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async="false";
xmldoc.loadXML(xml);
}
else
{
xmldoc = document.implementation.createDocument("","",null);
var parser=new DOMParser();
xmldoc=parser.parseFromString(xml,"text/xml");
}
if (typeof(callback) == 'function')
{
index=WebObject_Add(webhttp) ;
webhttp.xmlhttp.open("POST", url , true) ;
webhttp.xmlhttp.onreadystatechange = WebObject_Callback ;
webhttp.xmlhttp.send(xmldoc);
xmldoc=null ;
return(index) ;
}
else
{
webhttp.xmlhttp.open("POST", url , false) ;
webhttp.xmlhttp.send(xmldoc);
var exml='' ;
var tag = '//RETURN_VALUE' ;
exml=webhttp.xmlhttp.responseText;
xmldoc=null ;
webhttp=null ;
return(exml) ;
}
}
catch(e)
{
// alert(e.message);
}
finally
{
document.body.removeChild(divPlan);
}
} 展开
{
try
{
var divPlan=document.createElement("div");
divPlan.innerHTML="<table width='100%' height='100%'><tr><td align='center' valign='middle'>读取数据中,请稍候……</td></tr></table>";
divPlan.style.styleFloat = "right";
divPlan.style.position= "absolute";
divPlan.style.margin = "auto";
divPlan.style.top = "10px";
divPlan.style.left = "10px";
divPlan.style.border = "1px solid #DDD";
divPlan.style.width = "200px";
divPlan.style.height = "30px";
divPlan.style.background = "#FFFFE0";
divPlan.style.filter = "alpha(opacity=90)";
divPlan.style.opacity = "0.90";
divPlan.style.zIndex = "999";
divPlan.style.display = "block";
document.body.appendChild(divPlan);
var xmldoc;
var webhttp = new WebObject(callback);
var index ;
var params = new Array;
var pn = 0;
var len = WebService.arguments.length;
for (var i=3; i < len; i++)
params[pn++] = WebService.arguments[i];
var cmd="WebObject_XML('" + method + "'";
for (var i=0; i < params.length; i++)
cmd += ",'" + escape(params[i]) + "'";
cmd += ")" ;
var xml=eval(cmd) ;
if(window.ActiveXObject)
{
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async="false";
xmldoc.loadXML(xml);
}
else
{
xmldoc = document.implementation.createDocument("","",null);
var parser=new DOMParser();
xmldoc=parser.parseFromString(xml,"text/xml");
}
if (typeof(callback) == 'function')
{
index=WebObject_Add(webhttp) ;
webhttp.xmlhttp.open("POST", url , true) ;
webhttp.xmlhttp.onreadystatechange = WebObject_Callback ;
webhttp.xmlhttp.send(xmldoc);
xmldoc=null ;
return(index) ;
}
else
{
webhttp.xmlhttp.open("POST", url , false) ;
webhttp.xmlhttp.send(xmldoc);
var exml='' ;
var tag = '//RETURN_VALUE' ;
exml=webhttp.xmlhttp.responseText;
xmldoc=null ;
webhttp=null ;
return(exml) ;
}
}
catch(e)
{
// alert(e.message);
}
finally
{
document.body.removeChild(divPlan);
}
} 展开
2个回答
展开全部
javascript 脚本,
20分解释这么多,太累了。
var divPlan=document.createElement("div");
//定义一个dive
//下面这么多都是定义这个div的样式的
divPlan.innerHTML="<table width='100%' height='100%'><tr><td align='center' valign='middle'>读取数据中,请稍候……</td></tr></table>";
divPlan.style.styleFloat = "right";
divPlan.style.position= "absolute";
divPlan.style.margin = "auto";
divPlan.style.top = "10px";
divPlan.style.left = "10px";
divPlan.style.border = "1px solid #DDD";
divPlan.style.width = "200px";
divPlan.style.height = "30px";
divPlan.style.background = "#FFFFE0";
divPlan.style.filter = "alpha(opacity=90)";
divPlan.style.opacity = "0.90";
divPlan.style.zIndex = "999";
divPlan.style.display = "block";
//定义完样式后,添加到页面
document.body.appendChild(divPlan);
//下面这个是模拟一个http 请求,调用web service
var xmldoc;
var webhttp = new WebObject(callback);
var index ;
var params = new Array;//定义一个数组
var pn = 0;
var len = WebService.arguments.length;//web service 的参数长度为3
for (var i=3; i < len; i++)
params[pn++] = WebService.arguments[i]; //给web service 参数赋值
//定义命令语句的字符串
var cmd="WebObject_XML('" + method + "'";
for (var i=0; i < params.length; i++)
cmd += ",'" + escape(params[i]) + "'";
cmd += ")" ;
var xml=eval(cmd) ;//这里执行这个命令
if(window.ActiveXObject)//判断浏览器类型 这个是微软的IE
{
//生成一个DOM 对象
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async="false";
xmldoc.loadXML(xml);
}
else
{
//除了微软的IE ,都调用这个方法生成一个DOM 对象
xmldoc = document.implementation.createDocument("","",null);
var parser=new DOMParser();
xmldoc=parser.parseFromString(xml,"text/xml");
}
if (typeof(callback) == 'function')
{
//定义http请求的参数 post 调用 url
index=WebObject_Add(webhttp) ;
webhttp.xmlhttp.open("POST", url , true) ;
webhttp.xmlhttp.onreadystatechange = WebObject_Callback ;
webhttp.xmlhttp.send(xmldoc);
xmldoc=null ;
return(index) ;//返回值是个int 类型的序号,具体做什么要看web service 怎么写的了
}
else
{
webhttp.xmlhttp.open("POST", url , false) ;
webhttp.xmlhttp.send(xmldoc);
var exml='' ;
var tag = '//RETURN_VALUE' ;
exml=webhttp.xmlhttp.responseText;
xmldoc=null ;
webhttp=null ;
return(exml) ;
}
}
//这里都是异常处理了,
catch(e)
{
// alert(e.message);
}
finally
{
document.body.removeChild(divPlan);
}
20分解释这么多,太累了。
var divPlan=document.createElement("div");
//定义一个dive
//下面这么多都是定义这个div的样式的
divPlan.innerHTML="<table width='100%' height='100%'><tr><td align='center' valign='middle'>读取数据中,请稍候……</td></tr></table>";
divPlan.style.styleFloat = "right";
divPlan.style.position= "absolute";
divPlan.style.margin = "auto";
divPlan.style.top = "10px";
divPlan.style.left = "10px";
divPlan.style.border = "1px solid #DDD";
divPlan.style.width = "200px";
divPlan.style.height = "30px";
divPlan.style.background = "#FFFFE0";
divPlan.style.filter = "alpha(opacity=90)";
divPlan.style.opacity = "0.90";
divPlan.style.zIndex = "999";
divPlan.style.display = "block";
//定义完样式后,添加到页面
document.body.appendChild(divPlan);
//下面这个是模拟一个http 请求,调用web service
var xmldoc;
var webhttp = new WebObject(callback);
var index ;
var params = new Array;//定义一个数组
var pn = 0;
var len = WebService.arguments.length;//web service 的参数长度为3
for (var i=3; i < len; i++)
params[pn++] = WebService.arguments[i]; //给web service 参数赋值
//定义命令语句的字符串
var cmd="WebObject_XML('" + method + "'";
for (var i=0; i < params.length; i++)
cmd += ",'" + escape(params[i]) + "'";
cmd += ")" ;
var xml=eval(cmd) ;//这里执行这个命令
if(window.ActiveXObject)//判断浏览器类型 这个是微软的IE
{
//生成一个DOM 对象
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async="false";
xmldoc.loadXML(xml);
}
else
{
//除了微软的IE ,都调用这个方法生成一个DOM 对象
xmldoc = document.implementation.createDocument("","",null);
var parser=new DOMParser();
xmldoc=parser.parseFromString(xml,"text/xml");
}
if (typeof(callback) == 'function')
{
//定义http请求的参数 post 调用 url
index=WebObject_Add(webhttp) ;
webhttp.xmlhttp.open("POST", url , true) ;
webhttp.xmlhttp.onreadystatechange = WebObject_Callback ;
webhttp.xmlhttp.send(xmldoc);
xmldoc=null ;
return(index) ;//返回值是个int 类型的序号,具体做什么要看web service 怎么写的了
}
else
{
webhttp.xmlhttp.open("POST", url , false) ;
webhttp.xmlhttp.send(xmldoc);
var exml='' ;
var tag = '//RETURN_VALUE' ;
exml=webhttp.xmlhttp.responseText;
xmldoc=null ;
webhttp=null ;
return(exml) ;
}
}
//这里都是异常处理了,
catch(e)
{
// alert(e.message);
}
finally
{
document.body.removeChild(divPlan);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询