title: Fail to Call WebServices in ASP.NET in Javascript
body: <p>I fail to call a webservice. What have I miss? @@</p>
  
  <p>I am trying to follow this instructions here: <a href="https://stackoverflow.com/questions/4106026/how-to-call-an-asp-net-web-service-in-javascript">How to call an ASP.Net Web Service in javascript</a></p>
  
  <p>And below are my codes, but fails to work.</p>
  
  <p>This is my webservice codes:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Web;
  using System.Web.Services;
  using System.Web.Services.Protocols;
  using System.Web.Script.Services;
  
  namespace Library
  {
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      [System.Web.Script.Services.ScriptService()]
      public class ReleaseSessionObject : System.Web.Services.WebService
      {
          [WebMethod]
          public string HelloWord()
          {
              return "Hellow Word!";
          }
      }
  }
  </code></pre>
  
  <p>and this is my ASP.NET page codes:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="Library.WebForm6" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
  
      &lt;script src="ReleaseSessionObject.asmx" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function HelloWorld() {
              try {
                  var a = Library.ReleaseSessionObject.HelloWorld();
                  alert(a);
              }
              catch (err) {
                  alert(err.Message); 
              }
          };
      &lt;/script&gt;
  
      &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
        &lt;Services&gt;
          &lt;asp:ServiceReference Path="~/ReleaseSessionObject.asmx" /&gt;
        &lt;/Services&gt;
      &lt;/asp:ScriptManager&gt;
  
      &lt;input type="button" onclick="HelloWorld();" value="Click This" /&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>both ASP.NET page and Service files are located at the same folder.</p>
  
  <p>but when I click on the button. It says: <strong>undefined</strong></p>