我只是想通过GET将硬编码的JSON字符串传递给WCF AJax Enabled Web Service方法,我想接受它并将其写入数据库。我不得不注释$ .ajax的成功函数,以便现在不会出现Telerik的WebGrid错误。我怎样才能将其发送到Web服务:
var input = '{"SbiId":"ca222cf7-be5e-431a-ab93-9a31e8ae2f4a"}';
$(document).ready(function() {
// var input ='{"SbiId":"<%=guid %>"}';
console.log(input);
$.ajax({
url: "http://www.blah.com/services/testsService.svc/GetContactsDataAndCountbyGUID",
type: "GET",
contentType: "application/json; charset=utf-8",
data: input,
dataType: "json",
<%-- success: function(data) {
var mtv = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
console.log(data);
mtv.set_dataSource(data.d.Data);
mtv.dataBind();--%>
//}
});
编辑:服务参数是:
[OperationContract]
[WebGet]
public ResultData GetContactsDataAndCountbyGUID(string requestGUID)
{
配置为:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AlphaFrontEndSiteASP.TestsServiceAspNetAjaxBehavior">
<enableWebScript />
<webHttp />
</behavior>
<behavior name="AlphaFrontEndSiteASP.Services.TestsService">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="AlphaFrontEndSiteASP.Services.TestsService" behaviorConfiguration="MetadataBehavior">
<endpoint address="" behaviorConfiguration="AlphaFrontEndSiteASP.TestsServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="AlphaFrontEndSiteASP.Services.TestsService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>