title: calling asmx web service method with jquery ajax
body: <p>I have hosted web application with simple asmx web service in IIS 7.5 </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Services;
  
  namespace TestWebService
  {
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      [System.Web.Script.Services.ScriptService]
      public class Test : System.Web.Services.WebService
      {
          [WebMethod]
          public static string HelloWorld()
          {
              return "Hello World";
          }
  
      }
  }
  </code></pre>
  
  <p>when I click invoke button in <code>http://localhost/Test/Test.asmx?op=HelloWorld</code> it works fine but when I try to call this method by using $.ajax() from diffrent web application project which is running on ASP.NET development server (<code>http://localhost:1756/HTMLPage1.htm</code>) I got an error response.status as 0 and can't call the web method and here's my code.</p>
  
  <pre><code>&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&gt;
      &lt;title&gt;Consume Test &lt;/title&gt;
      &lt;script src="jquery-1.5.1.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
          function displayMessageCall() {
  
              $.ajax({
                  type: "POST",
                  url: "http://localhost/Test/Test.asmx/HelloWorld",
                  data: '{}',
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: successMsg,
                  error: errorMsg
  
              });
          }
  
          function successMsg(response) {
              alert('Success');
          }
  
          function errorMsg(response) {
              alert(response.status + " " + response.statusText)
          }
  
          $(document).ready(function () {
              displayMessageCall();
          });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Am I missing something?</p>