title: How to call webservice using javascript
body: <p>I am using below code to call webservice using javascript:</p>
  
  <pre><code>&lt;head&gt;
      &lt;title&gt;Untitled Page&lt;/title&gt;
         &lt;script type="text/javascript" language="JavaScript"&gt;
        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);
        }
       &lt;/script&gt;
  &lt;/head&gt;
  &lt;body  onload="InitializeService()" id="service" &gt;
  &lt;a id="ViewLink"   href="http://"  onclick="registerUser()"  style="behavior:url(webservice.htc);" onresult="onmyresult();"&gt; &lt;font color=maroon&gt;Call&lt;/font&gt;&lt;/a&gt;
    &lt;input id="Text1" type="text" /&gt;
          &lt;input id="Text2" type="text" /&gt;
          &lt;input id="Button1" type="button" value="Save" onclick="registerUser();" /&gt;     
  &lt;/body&gt;
  </code></pre>
  
  <p>But i am getting error:"The url is not valid and cannot be loaded"</p>
  
  <p>i done the above code with help of below urls but i checked both samples in these url are not working:</p>
  
  <p><a href="http://www.codeproject.com/KB/webservices/callWebServiceUsingJS.aspx" rel="nofollow">http://www.codeproject.com/KB/webservices/callWebServiceUsingJS.aspx</a></p>
  
  <p><a href="http://www.codeproject.com/KB/webservices/CallWebServiceFromHtml.aspx" rel="nofollow">http://www.codeproject.com/KB/webservices/CallWebServiceFromHtml.aspx</a></p>
  
  <p>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.</p>
  
  <p>Please help me.
  Thanks</p>