Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF service call fails while Calling WCF service using JQuery
    text
    copied!<p>I am using asp.net. I have created an WCF service in C# and hosted on IIS server. I am calling this service using JQuery in my asp.net web application. When I called the service using JQuery, it is going to error function and in alert there is empty message. </p> <p>Calling service form .aspx page. </p> <pre><code>&lt;script src="Script/jquery-1.10.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" language="javascript"&gt; function callService() { var value = 10; $.ajax({ type: "POST", url: "http://localhost/IISWCF/Service1.svc/getdata", contentType: "application/json; charset=utf-8", data: '{"value": "' + value + '"}', dataType: "json", processdata: true, //True or False error: function(XMLHttpRequest, textStatus, errorThrown) { alert("error: " + errorThrown); }, success: function(msg) { alert(msg.d); } }); } &lt;/script&gt; &lt;script type="text/javascript" language="javascript"&gt; $(document).ready(function(){ callService(); }) &lt;/script&gt; </code></pre> <p>Service1.svc file </p> <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 : IService1 { public string GetData(int value) { return string.Format("You entered: {0}", value); } } </code></pre> <p>IService1.cs file </p> <pre><code>namespace WcfService1 { [ServiceContract] public interface IService1 { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)] string GetData(int value); } } </code></pre> <p>WCF Web.config file</p> <pre><code> &lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="WcfService1.Service1Behavior"&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="EndpBehavior"&gt; &lt;webHttp/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;services&gt; &lt;service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior"&gt; &lt;endpoint behaviorConfiguration="EndpBehavior" address="" binding="webHttpBinding" contract="WcfService1.IService1"&gt; &lt;identity&gt; &lt;dns value="localhost"/&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt; &lt;/service&gt; &lt;/services&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt; &lt;/system.serviceModel&gt; </code></pre> <p>Please help me to resolved this issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload