Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is wrong with this call to a WCF service from jQuery?
    primarykey
    data
    text
    <p>This function is wired up to the click event of a button:</p> <pre><code>function BlahBlahBlahWCFXML() { varType = "POST"; varUrl = "http://123.123.123.123/NameOfService.svc/GetStuffById"; varData = '{"stuffId": "' + 12345678-abcd-9012-3456-abcdefghjkl' + '"}'; varContentType = "application/json; charset=utf-8"; varDataType = "xml"; varProcessData = true; CallService(); } </code></pre> <p>That function then calls this one:</p> <pre><code>//Generic function to call AXMX/WCF Service function CallService() { $.ajax({ type : varType, //GET or POST or PUT or DELETE verb url : varUrl, // Location of the service cache : false, data : varData, //Data sent to server contentType : varContentType, // content type sent to server dataType : varDataType, //Expected data format from server processdata : varProcessData, //True or False success : function(msg) {//On Successfull service call ServiceSucceeded(msg); }, error: ServiceFailed// When Service call fails }); } </code></pre> <p>When I try to run the sample, I get the following in Google Chrome's developer tools, console window:</p> <p>Failed to load resource: the server responded with a status of 400 (Bad Request) XMLHttpRequest cannot load <a href="http://123.123.123.123/NameOfService.svc/GetStuffById" rel="nofollow">http://123.123.123.123/NameOfService.svc/GetStuffById</a>. Origin null is not allowed by Access-Control-Allow-Origin.</p> <p>The service is working fine and I'm currently calling it from webforms and console apps. GetStuffById is the method I want to call. It accepts a string (GUID in this case) as a parameter and returns a string.</p> <p>The service is a WCF service and is configured to return a SOAP message. I'd prefer JSON but that's another issue for another question some other day.</p> <p>Any ideas what's going on here? Thanks!</p> <p>UPDATE #1 - I changed the POST to a GET. Still no-go.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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