1
我在使用wcf服務時遇到問題。在ajax中的響應將會出現錯誤函數。該網址是完全正確的。在jquery中使用wcf服務
$.ajax({
type: "post",
url: "http://192.168.1.3:16150/ajaxnewclinicalhost/Service.svc/gettablejson1",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
},
error: function() {
alert("error");
}
});
的Web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /></assemblies></compilation>
</system.web>
<system.serviceModel>
<services>
<service name="newclinicallibrary.Service1">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="" behaviorConfiguration="WEB" contract="newclinicallibrary.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WEB">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
瀏覽器中的URL是否具有匹配的IP和端口? – alex 2011-03-15 11:38:15
請向我們展示您的服務器端配置('web.config'和'service.svc'文件)!沒有它,我們不可能知道什麼可能會出錯.... – 2011-03-15 11:40:49
我已經添加web.config請檢查 – user601367 2011-03-15 12:06:00