Как позвонить в крест домена службы WCF из jQuery и AJAX с параметрами
I have one Cross Domain WCF. I have already implemented the CORS on the service. If the method don't have any parameter, then I can call it using JQuery Ajax. But the problem is, when the method is having any parameter then some error is occurred after the JQuery Ajax call.
$.support.cors = true; $.ajax({ url: servicePath, crossDomain: true, type: 'POST', async: false, cache: false, data: '{"name": "xyz"}', contentType: "application/json; charset=utf-8", dataType: 'json', processData: true, success: function (response) { alert('s'); }, error: function (error) { alert(error.status + ' : ' + error.statusText); } })
[ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 { [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] public string GetName(string name) { return "Result !"; } }
Что я уже пробовал:
Код уже упоминался выше.