我有一个 wfc 服务,它正在使用 jquery ajax 调用 taht 调用返回 json 数据。没有返回数据或错误。当我将网址放入浏览器时,它会返回数据。例如
{"Title":"The Prestige","Year":"2006"}
这是我的服务合同
[ServiceContract]
public interface IMovies
{
[OperationContract]
[WebGet(UriTemplate="/movies", ResponseFormat=WebMessageFormat.Json)]
Movie GetMovies();
}
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="Movies">
<endpoint address="" behaviorConfiguration="web"
binding="webHttpBinding" contract="IMovies" />
</service>
</services>
还有我的 ajax 调用
$.ajax({
type: "GET",
url: "http://server/Service/Movies.svc/movies",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var movie = response.d;
$("#movieTitle").text(movie.Title);
$("#movieYearHidden").val(movie.Year);
$("#game").show();
},
error: function(response) {
alert("Error retrieving movie. Please check connection.");
}
});
当我拨打电话时,没有任何反应。请帮忙