javascript引用webservice报错:oResult.id为空或不是对象 var oResult = event.srcElement 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var oResult = event.srcElement <script language="javascript" type="text/javascript"> var iCallID = null; var sWSDL = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL"; function callWService() { Service.useService(sWSDL,"WS"); Service = oService.WS.callService("cn.com.webxml.www.WeatherWebService","上海"); } </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> </title> </head> <body onload="callWService()"> <div id="Service" style="behavior:url(webservice.htc)"> </div> </body> </html> 改了改,可以出来了<script language="javascript" type="text/javascript"> var oService = document.getElementById('Service');var iCallID = null; var sWSDL = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL"; function callWService(){ Service.useService(sWSDL,"WeatherWebService"); iCallID = Service.WeatherWebService.callService(callback,"getWeatherbyCityName",'福州'); alert(iCallID);} function callback(res){ if(res.error){ document.all.a1.value = 'error:\n1:' + res.errorDetail.code; document.all.a1.value += '\n2:' + res.errorDetail.String; document.all.a1.value += '\n3:' + res.errorDetail.raw; } else{ var obj = res.value; document.all.a1.value = res.raw.xml; alert(res.value); if(typeof(obj) == 'object'){ //document.all.a1.value = (res.raw.xml); var xml = res.raw.xml; if(xml != null && xml != ""){ //var xmlDoc = new ActiveXObject("MSXml2.XMLDOCUMENT"); var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0"); xmlDoc.async=false; xmlDoc.validateOnParse=false; xmlDoc.setProperty("ServerHTTPRequest",true ); xmlDoc.loadXML(xml); var arrStr = xmlDoc.getElementsByTagName("string"); for(var i=0;i<arrStr.length;i++){ alert(arrStr[i]); } } } else{ document.all.a1.value = (res.value); } } }</script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> </title> </head> <body onload="callWService()"> <div id="Service" style="behavior:url(webservice.htc)"> <textarea name="a1" rows="50" cols="100"></textarea> <div id="a2"></div></div> </body> </html> To Youbl:运行,报错:Service.useService(sWSDL,"WeatherWebService");对象不支持此方法或属性 没问题了,是webservice.htc文件有问题,重新覆盖一边就好了,谢谢! asp循环调用的问题 急求论坛里的高手解决,高分报答大家的支持!!! javascript 点击总代理商占成数后自动分配代理占成数 有个问题 ~~~~~ 在JAVASCRIPT,怎样在一个TEXTAREA 中依次增加内容! 我出200分---请各位高手帮忙把这段代码升个级 另外100分就在附近 关于IFRAME,传值得问题,希望大家帮帮忙。 对表格进行动态排序!分不是问题! 请教javascript菜单问题 请教怎么修改下面的代码(在IE正常)以适合FF,关于childNodes 子对是如何影响父对象的?
var iCallID = null;
var sWSDL = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL"; function callWService()
{
Service.useService(sWSDL,"WS");
Service = oService.WS.callService("cn.com.webxml.www.WeatherWebService","上海");
} </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
</head>
<body onload="callWService()">
<div id="Service" style="behavior:url(webservice.htc)"> </div>
</body>
</html>
<script language="javascript" type="text/javascript">
var oService = document.getElementById('Service');
var iCallID = null;
var sWSDL = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL"; function callWService(){
Service.useService(sWSDL,"WeatherWebService");
iCallID = Service.WeatherWebService.callService(callback,"getWeatherbyCityName",'福州');
alert(iCallID);
} function callback(res){
if(res.error){
document.all.a1.value = 'error:\n1:' + res.errorDetail.code;
document.all.a1.value += '\n2:' + res.errorDetail.String;
document.all.a1.value += '\n3:' + res.errorDetail.raw;
}
else{
var obj = res.value;
document.all.a1.value = res.raw.xml;
alert(res.value);
if(typeof(obj) == 'object'){
//document.all.a1.value = (res.raw.xml);
var xml = res.raw.xml;
if(xml != null && xml != ""){
//var xmlDoc = new ActiveXObject("MSXml2.XMLDOCUMENT");
var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
xmlDoc.async=false;
xmlDoc.validateOnParse=false;
xmlDoc.setProperty("ServerHTTPRequest",true );
xmlDoc.loadXML(xml);
var arrStr = xmlDoc.getElementsByTagName("string");
for(var i=0;i<arrStr.length;i++){
alert(arrStr[i]);
}
}
}
else{
document.all.a1.value = (res.value);
}
}
}</script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
</head>
<body onload="callWService()">
<div id="Service" style="behavior:url(webservice.htc)">
<textarea name="a1" rows="50" cols="100"></textarea>
<div id="a2"></div>
</div>
</body>
</html>
运行,报错:
Service.useService(sWSDL,"WeatherWebService");
对象不支持此方法或属性