title: Call Wcf service with Javascript in Html page
body: <p>I have a WCF project in VSStudio2012 and I want to call a method from JavaScript function.</p>
  
  <p>JavaScript file : </p>
  
  <pre><code>var url = 'http://localhost:52768/Service1.svc/'
  
  function test() {
  
  var response;
  
  $.ajax({
      type: 'Post',
      url: url + 'GetTEST',
      contentType: 'application/json; charset=utf-8',
      dataType: 'json',
      success: function (msg) {
          alert(msg);
      },
  
      error: function (e) {
          alert("Error  : " + e.statusText);
      }
  });
  </code></pre>
  
  <p>}</p>
  
  <p>HTML file : </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;script Language="JavaScript" src="Scripts/JavaScript1.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery-1.9.1.intellisense.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery-1.9.1.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery.unobtrusive-ajax.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery.unobtrusive-ajax.min.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery.validate.js"&gt;&lt;/script&gt;
  &lt;script Language="JavaScript" src="Scripts/jquery.validate.min.js"&gt;&lt;/script&gt;
  &lt;title&gt;TESTE&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;input id="Button1" type="button" value="button" onclick="test()"/&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>In my IService1.cs</p>
  
  <pre><code>    [OperationContract]
      [WebInvoke(Method = "GET",ResponseFormat = WebMessageFormat.Json)]
      string GetTEST();
  </code></pre>
  
  <p>Here is that alert display </p>
  
  <p><img src="https://i.stack.imgur.com/jefQF.png" alt="enter image description here"></p>
  
  <p>And the error :</p>
  
  <p><img src="https://i.stack.imgur.com/LLoqT.png" alt="enter image description here"></p>
  
  <p>localhost:52768/Service1.svc display</p>
  
  <p><img src="https://i.stack.imgur.com/d8xC1.png" alt="enter image description here"></p>