为了手机看些宣传 加载速度为了快
采用纯html 利用js加载写好webservice 在页面显示数据
2个问题
一,脚本函数我自己写的读不出来 呵呵 技术差求指教
二,xml list解析
谢谢大虾指导<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ly.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <title>Hello World</title>
<script language="JavaScript">
var iCallID;
function InitializeService(){
service.useService("futstar.wlwlw.net/NodeService.asmx?WSDL", "GetAllNodes");
service.HelloWorldService.callService("HelloWorld");
}
function ShowResult(){
alert(event.result.value);
}
</script>
</head>
<body onload="InitializeService()" id="service"
style="behavior:url(webservice.htc)" onresult="ShowResult()"> </body>
</html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ly3.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function hcr()
{
};
function getfemale()
{
//第一个参数是webservice的url,后面是名称
female.useService("futstar.wlwlw.net/NodeService.asmx?WSDL","NodeService");
//设置一个回调函数,service返回结果的时候回调;第一个参数是回调函数的名称,后面的是webservice的参数
intCallID=female.news.callService(female_result,"GetAllNodes","list"); //这里有两个参数.....
}
function female_result(result)//回调函数
{
if(result.error)
{
female.innerHTML=result.errorDetail.string;
}
else
{
female.innerHTML=result.value; //将webservice返回的结果写如div中
}
}
</script>
<style type="text/css">
.hcr{
onmouseover.this.class="xxx"}
</style>
</head>
<body>
<img id="hcr" src="img/1.png" onmouseover="this.src='img/2.png';getfemale();" onmouseout="this.src='img/1.png'"/>
<div id="female" style="BEHAVIOR:url(WebService.htc)"></div>
</body>
</html>
采用纯html 利用js加载写好webservice 在页面显示数据
2个问题
一,脚本函数我自己写的读不出来 呵呵 技术差求指教
二,xml list解析
谢谢大虾指导<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ly.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <title>Hello World</title>
<script language="JavaScript">
var iCallID;
function InitializeService(){
service.useService("futstar.wlwlw.net/NodeService.asmx?WSDL", "GetAllNodes");
service.HelloWorldService.callService("HelloWorld");
}
function ShowResult(){
alert(event.result.value);
}
</script>
</head>
<body onload="InitializeService()" id="service"
style="behavior:url(webservice.htc)" onresult="ShowResult()"> </body>
</html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ly3.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function hcr()
{
};
function getfemale()
{
//第一个参数是webservice的url,后面是名称
female.useService("futstar.wlwlw.net/NodeService.asmx?WSDL","NodeService");
//设置一个回调函数,service返回结果的时候回调;第一个参数是回调函数的名称,后面的是webservice的参数
intCallID=female.news.callService(female_result,"GetAllNodes","list"); //这里有两个参数.....
}
function female_result(result)//回调函数
{
if(result.error)
{
female.innerHTML=result.errorDetail.string;
}
else
{
female.innerHTML=result.value; //将webservice返回的结果写如div中
}
}
</script>
<style type="text/css">
.hcr{
onmouseover.this.class="xxx"}
</style>
</head>
<body>
<img id="hcr" src="img/1.png" onmouseover="this.src='img/2.png';getfemale();" onmouseout="this.src='img/1.png'"/>
<div id="female" style="BEHAVIOR:url(WebService.htc)"></div>
</body>
</html>
解决方案 »
- iframe标签里插入embed标签
- 记得前段时间我看见过jQuery1.4支持iframe跨域访问来设置高度的,但是找不到了
- jquery中的 each方法中的参数问题
- 还是有关div动态创建设置属性的问题
- 急!使用AJAX数据列表不能更新
- 下拉菜单传值
- 谁给解释下这个含义啊 var myArray = [[[]]]
- style="width:expression(screen.width-0)"中的expression是什么意思,有什么用?
- 求问菜单跳转问题
- jQuery的get方法为什么能在error后还会执行success中的内容?
- cmd.Execute() 报错行只有这么一段代码,如何调试错误在哪
- html 用js直接加载webservice xml对象 list
[code=HTM]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ly3.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="js/mootools.v1.11.js" type="text/javascript"></script>
<script src="js/WebService.js" type="text/javascript"></script>
<script type="text/javascript">
var service ;
function ajaxRequest()
{
var url = "http://futstar.wlwlw.net/NodeService.asmx";
//http://futstar.wlwlw.net/NodeService.asmx?op=GetAllNodeErrorDevices
//设置webService传入参数
//
//注意:
//
// 调用webservice(如例子中的webservicedemo.asmx)
// HelloTo(String name) 针对name参数必须写成name=wqj ,还有更多参数一样写,使用&符号分隔(name=11&age=20&.....),使用名称匹配
// 传入的参数数量可以不等于(多于或少于)方法要求的参数
var para = "areaId=8";
var op = {
data:para,
onComplete: showResponse,
onFailure:showError,
update:'ajaxBack'
}; service = new WebService(url,"GetAllNodes",op);
service.request();
return false;
}
function showError(obj)
{
//obj 是一个xmlHttpRequest对象
alert("error");
}
function showResponse(requestText,requestXML)
{
//requestText
//requestXML
//requestText 返回的文本
//requestXML 返回的XML
// service.getBackData 就是取出返回的XML中,实际需要的数据
//经过测试兼容 IE,FF
alert(service.getBackData(requestXML)+"html");
var c = requestText;
var b = requestXML;
alert(b);
}
</script> </head>
<body background="../jiaju.jpg" onLoad="ajaxRequest()">
<div >
<img id="hcr" src="img/1.png" onMouseOver="this.src='img/2.png';" onmouseout="this.src='img/1.png'" />
</div>
<div id="ajaxBack">uhiuiui</div>
</body>
</html>[/code]
[code=JScrip]var WSDLS = {};var WebService = new Class({ url : '',
method : '',
options:
{
method:'GET',
data: null,
update: null,
onComplete: Class.empty,
onError:Class.empty,
evalScripts: false,
evalResponse: false
},
initialize: function(url,method,options)
{
this.url = url;
this.method = method;
this.options = options;
},
request : function()
{
var wsdl = WSDLS[this.url];
if(!wsdl)
{
var op = {method:'GET',async: false};
var wsdlAjax = new XHR(op).send(this.url + "?wsdl", null);
wsdl = wsdlAjax.transport.responseXML;
WSDLS[this.url] = wsdl;
} this.setSoap(wsdl);
},
setSoap : function(wsdl)
{
var paraXML = this.getParaXML(wsdl);
alert(paraXML);
var ns = (wsdl.documentElement.attributes["targetNamespace"] + "" == "undefined") ? wsdl.documentElement.attributes.getNamedItem("targetNamespace").nodeValue : wsdl.documentElement.attributes["targetNamespace"].value;
var sr =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<" + this.method + " xmlns=\"" + ns + "\">" +
paraXML +
"</" + this.method + "></soap:Body></soap:Envelope>";
this.options.method = 'post';
this.options.data = null;
var soapaction = ((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + this.method; var soapAjax = new Ajax(this.url,this.options);
soapAjax.setHeader("SOAPAction", soapaction);
soapAjax.setHeader("Content-type", "text/xml; charset=utf-8");
soapAjax.request(sr);
},
getParaXML : function(wsdl)
{
var objNode = null;
var rtnValue = "";
//java(xfire)
var ell = this.getElementsByTagName(wsdl,"xsd:element");
if(ell.length == 0)
{
//c#
ell = this.getElementsByTagName(wsdl,"s:element");
}
for(var i = 0; i < ell.length; i++)
{
if(this.getElementAttrValue(ell[i],"name") == this.method)
{
objNode = ell[i];
break;
}
} if(objNode == null) return rtnValue;
//java(xfire)
ell = this.getElementsByTagName(objNode,"xsd:element");
if(ell.length == 0)
{
//c#
ell = this.getElementsByTagName(objNode,"s:element");
}
if(ell.length == 0) return rtnValue ;
var hash = new Hash();
if(this.options.data != null && this.options.data.clean != "")
{
hash = this.options.data.split("&").toHash("=");
}
for(var i = 0; i < ell.length; i++)
{
var paraName = this.getElementAttrValue(ell[i],"name");
rtnValue = rtnValue + this.getSingleXML(paraName,hash);
}
return rtnValue;
},
getSingleXML : function (name,hash)
{
name = name.trim();
var rtnValue = "";
if(hash.hasKey(name))
{
rtnValue = hash.get(name);
}
rtnValue = "<" + name + ">" + xmlscc(rtnValue) + "</" + name + ">"
return rtnValue;
},
getBackData: function(xml)
{
var rtnValue = "";
//java(xfire)
var soap = this.getElementsByTagName(xml,"ns1:out");
if(soap.length == 0)
{
//c#
soap = this.getElementsByTagName(xml,this.method + "Result");
}
return soap[0].childNodes[0].nodeValue;
},
getElementsByTagName : function(objNode,tagName)
{
//tagName 形式如 xsd:element ,写出tag的全称 var ell;
if(this.isIE())
{
ell = objNode.getElementsByTagName(tagName);
}
else
{
if(tagName.contains(":")) tagName = tagName.split(":")[1];
ell = objNode.getElementsByTagName(tagName);
}
return ell;
},
getElementAttrValue : function(objNode,attrName)
{
var rtnValue = "";
if(objNode == null) return rtnValue;
if(objNode.attributes[attrName] + "" == "undefined")
{
if(objNode.attributes.getNamedItem(attrName) != null)
rtnValue = objNode.attributes.getNamedItem(attrName).nodeValue ;
}
else
{
if(objNode.attributes[attrName] != null)
rtnValue = objNode.attributes[attrName].value;
}
return rtnValue;
},
isIE : function()
{
var isMSIE = /*@cc_on!@*/false;
return isMSIE;
}
});Array.extend({
toHash : function (splitChar)
{
var hash = new Hash({});
for(var i=0;i<this.length;i++)
{
if(this[i].split(splitChar).length == 1) contrnue; var key = this[i].split(splitChar)[0].trim();
var value = this[i].split(splitChar)[1].trim();
hash.set(key, value);
}
return hash;
}
});function xmlscc(strData)
{ strData=strData.replace(/&/g, "&");
strData=strData.replace(/>/g, ">");
strData=strData.replace(/</g, "<");
strData=strData.replace(/"/g, """);
strData=strData.replace(/'/g, "'");
return strData;
}
[/code]