title: How to call WebService client-side?
body: <p>I am trying to access webservice from client-side using javascript. I have created webservice successfully. I have used it in Website project successfully, but it is Web Application project.</p>
  
  <p>Here is my HTML code  </p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;script type="text/javascript"&gt;
          function Test() {
              WebService1.HelloWorld(onS, onF);
          }
          function onS(r) { alert("Result"); }
          function onF(er) { alert("Error"); }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
              &lt;Services&gt;
                  &lt;asp:ServiceReference InlineScript="true" Path="~/WebService1.asmx"/&gt;
              &lt;/Services&gt;
          &lt;/asp:ScriptManager&gt;
          &lt;input type="button" value="Call Service" onclick="Test()" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is WebService code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Services;
  
  namespace TestWebService
  {
      /// &lt;summary&gt;
      /// Summary description for WebService1
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      [System.Web.Script.Services.ScriptService]
      public class WebService1 : System.Web.Services.WebService
      {
  
          [WebMethod]
          public string HelloWorld()
          {
              return "Hello World";
          }
      }
  }
  </code></pre>
  
  <p>Now this code is not working. </p>
  
  <p>I am using framework 3.5 and VS2012. </p>