Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot complete a JSONP call from jQuery to WCF
    text
    copied!<p>Okay, I am trying (poorly) to successfully make a JSONP call from jQuery on a test page to a WCF web service running locally, as a cross-domain call. I have, at one point or another, either gotten a 1012 URI denied error, gotten a response but in Xml, or just had no response at all. Currently, the way I have it configured it spits back a 1012. </p> <p>I did not write this web service, so it is entirely possible that I am just missing a configuration setting <em>somewhere</em>, but I've become so frustrated with it that I think just asking on here will be more productive. Thanks guys. Details below.</p> <p>I have a WCF web service with the following method:</p> <pre><code>[ScriptMethod(ResponseFormat = ResponseFormat.Json)] public decimal GetOrderStatusJson(int jobId) </code></pre> <p>I am trying to call this method from a jQuery test page, via a cross-domain JSONP call.</p> <pre><code>&lt;script type="text/javascript"&gt; getJsonAjaxObject( "http://localhost:3960/ProcessRequests.svc/json/GetOrderStatusJson", { "jobId": 232 }); function getJsonAjaxObject(webServiceUrl, jsonData) { var request = { type: "POST", contentType: "application/json; charset=utf-8", url: webServiceUrl, data: jsonData, dataType: "jsonp", success: function(msg) { //success! alert("blah"); }, error: function() { //oh nos alert("bad blah"); } }; $.ajax(request); } &lt;/script&gt; </code></pre> <p>Below are the chunks of the web.config I configure for this purpose: </p> <pre><code>&lt;services&gt; &lt;service behaviorConfiguration="MWProcessRequestWCF.ProcessRequestsBehavior" name="MWProcessRequestWCF.ProcessRequests"&gt; &lt;endpoint address="json" behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" contract="MWProcessRequestWCF.IProcessRequests" /&gt; &lt;endpoint address="" binding="wsHttpBinding" contract="MWProcessRequestWCF.IProcessRequests"&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;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="MWProcessRequestWCF.ProcessRequestsBehavior"&gt; &lt;serviceMetadata httpGetEnabled="true"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="AspNetAjaxBehavior"&gt; &lt;enableWebScript/&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; </code></pre>
 

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