Saturday, May 11, 2024
155
rated 0 times [  159] [ 4]  / answers: 1 / hits: 25250  / 14 Years ago, wed, february 23, 2011, 12:00:00

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.com/KB/webservices/callWebServiceUsingJS.aspx



http://www.codeproject.com/KB/webservices/CallWebServiceFromHtml.aspx



NOTE: my web service is live and i am able to consume it using asp.net but i am facing issue for using it in javascript.



Please help me.
Thanks


More From » web-services

 Answers
23

If 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.


[#93620] Monday, February 21, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emiliano

Total Points: 381
Total Questions: 109
Total Answers: 93

Location: Jersey
Member since Fri, Oct 1, 2021
3 Years ago
emiliano questions
;