Can';t从jQuery调用WCF服务

Can';t从jQuery调用WCF服务,wcf,jquery,Wcf,Jquery,有十几篇文章介绍了如何从jQuery调用WCF方法,我无法让它工作。我有一个简单的WCF服务应用程序 [ServiceContract] public interface IService1 { [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseF

有十几篇文章介绍了如何从jQuery调用WCF方法,我无法让它工作。我有一个简单的WCF服务应用程序

[ServiceContract]
public interface IService1
{

    [OperationContract]
    [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    string GetData(int value);

 }
这就是实现

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{

    public string GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }
}
这是我服务的web.config

<system.serviceModel>
<behaviors>
  <endpointBehaviors>
    <behavior name="TestWebApp.Service1AspNetAjaxBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="TestWebApp.Service1AspNetAjaxBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />
<services>
  <service name="jQueryToWCF.Service1">
    <endpoint address="" 
              behaviorConfiguration="TestWebApp.Service1AspNetAjaxBehavior"
              binding="webHttpBinding" 
              contract="jQueryToWCF.IService1" />
  </service>
</services>

但连电话都没打。我用小提琴手检查了一下。但当我将url放入浏览器时,我可以得到响应。有人能帮我弄明白吗?

我已经断断续续地挣扎了一段时间

最终让我感动的一页是:

同时:这里有一个功能项目文件,应该可以工作。您可能需要将javascript中的url替换为正确的端口#


此外,这篇CodeProject文章是我第一次真正开始工作的跨域调用示例。当我与上面的项目集成时,我将发布一个更新的文件,该文件使用jsonp跨域:——这一个跨域工作。
$(document).ready(function () {
        var param = "{value: 'Hello World!'}";
        $.ajax({
            type: "GET",
            url: "http://localhost:5555/Service1.svc/GetData",
            data: param,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                alert(result.d);
            }
        });
    });