我正在使用已下载的 WCF jQuery AJAX 调用示例。我可以运行它并让它在同一个项目中工作。当我从同一解决方案中的不同项目访问相同内容时,它什么也不做。以下是我正在调用的方法。
function WCFJSON() {
var parameter = "1234567890 (Cross Domain)";
Type = "GET";
Url = "http://localhost:52729/jQueryWebSite/Service.svc/Test?Id=" + parameter;
Data = '{"Id": "' + parameter + '"}';
ContentType = "application/json; charset=utf-8";
DataType = "jsonp"; ProcessData = false;
CallService();
}
$(document).ready(function () {
WCFJSON();
});
我在成功和失败方法中有 alert()。
当我直接在浏览器中运行 URL 时,它会返回结果。但如果我从另一个项目运行它,它什么也不做。没有警报,没有结果。
以下是我的服务正在运行的项目的 Web.Config;
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
</compilation>
<authentication mode="Windows"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" binding="webHttpBinding" contract="IService" behaviorConfiguration="EndpBehavior"/>
</service>
</services>
</system.serviceModel>
</configuration>
是否与 Web.config 或脚本中的任何错误有关?我遵循了许多方法并尝试了各种方法。