admin管理员组文章数量:1349199
I am using below code to call webservice using javascript:
<head>
<title>Untitled Page</title>
<script type="text/javascript" language="JavaScript">
service = document.getElementById("ViewLink");
function InitializeService(){
service.useService('http://myURL/cloudtalk/cloudservice.asmx?wsdl',"CloudService");
}
var regtype, regvalue;
function registerUser(){
regtype = document.getElementById("Text1").value;
regvalue =document.getElementById("Text2").value;
service.CloudService.callService("register", regtype, regvalue);
}
function ShowResult(){
alert(event.result.value);
}
</script>
</head>
<body onload="InitializeService()" id="service" >
<a id="ViewLink" href="http://" onclick="registerUser()" style="behavior:url(webservice.htc);" onresult="onmyresult();"> <font color=maroon>Call</font></a>
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Button1" type="button" value="Save" onclick="registerUser();" />
</body>
But i am getting error:"The url is not valid and cannot be loaded"
i done the above code with help of below urls but i checked both samples in these url are not working:
.aspx
.aspx
NOTE: my web service is live and i am able to consume it using asp but i am facing issue for using it in javascript.
Please help me. Thanks
I am using below code to call webservice using javascript:
<head>
<title>Untitled Page</title>
<script type="text/javascript" language="JavaScript">
service = document.getElementById("ViewLink");
function InitializeService(){
service.useService('http://myURL/cloudtalk/cloudservice.asmx?wsdl',"CloudService");
}
var regtype, regvalue;
function registerUser(){
regtype = document.getElementById("Text1").value;
regvalue =document.getElementById("Text2").value;
service.CloudService.callService("register", regtype, regvalue);
}
function ShowResult(){
alert(event.result.value);
}
</script>
</head>
<body onload="InitializeService()" id="service" >
<a id="ViewLink" href="http://" onclick="registerUser()" style="behavior:url(webservice.htc);" onresult="onmyresult();"> <font color=maroon>Call</font></a>
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Button1" type="button" value="Save" onclick="registerUser();" />
</body>
But i am getting error:"The url is not valid and cannot be loaded"
i done the above code with help of below urls but i checked both samples in these url are not working:
http://www.codeproject./KB/webservices/callWebServiceUsingJS.aspx
http://www.codeproject./KB/webservices/CallWebServiceFromHtml.aspx
NOTE: my web service is live and i am able to consume it using asp but i am facing issue for using it in javascript.
Please help me. Thanks
Share Improve this question edited Feb 23, 2011 at 7:04 Dr. Rajesh Rolen asked Feb 23, 2011 at 6:59 Dr. Rajesh RolenDr. Rajesh Rolen 14.3k42 gold badges110 silver badges180 bronze badges 5-
Does
http://myURL/cloudtalk/cloudservice.asmx?wsdl
in your browser? – deiga Commented Feb 23, 2011 at 7:01 - What about not using IE-only stuff? – ThiefMaster Commented Feb 23, 2011 at 7:03
- @i wants to consume my service in all browsers using javascript – Dr. Rajesh Rolen Commented Feb 23, 2011 at 7:05
- @deiga:my web service is live and i am able to consume it using asp but i am facing issue for using it in javascript. – Dr. Rajesh Rolen Commented Feb 23, 2011 at 7:06
- I think its not working because of cross domain, experts is it correct? – Dr. Rajesh Rolen Commented Feb 23, 2011 at 7:21
1 Answer
Reset to default 5If the web service URL has a different host (by domain name or port) than the one from which the HTML page is served then your JavaScript is violating the same origin policy and any browser will prevent the web service request from loading.
本文标签: web servicesHow to call webservice using javascriptStack Overflow
版权声明:本文标题:web services - How to call webservice using javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743858598a2551315.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论