Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:27:43+00:00 2026-06-06T18:27:43+00:00

I’m making a GET request against a WCF web service. My WCF service is

  • 0

I’m making a GET request against a WCF web service. My WCF service is located at http://localhost/RestService/RestService.svc/web/GetMessage and has the following interface:

[OperationContract]
[WebGet(UriTemplate = "GetMessage", ResponseFormat = WebMessageFormat.Json)]
String GetMessage();

The endpoint is configured properly as I can make a bare call within my browser:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WebServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
        <behavior name="WebEndpointBehavior">
          <webHttp />
          </behavior>
      </endpointBehaviors>
    </behaviors>

    <services>
      <service name="TestRestService.RestService"
               behaviorConfiguration="WebServiceBehavior">
        <endpoint name="RestWeb"
                  address="web"
                  binding="webHttpBinding"
                  behaviorConfiguration="WebEndpointBehavior"
                  contract="TestRestService.IRestService" />
      </service>
    </services>
  </system.serviceModel>

Calling it via navigation in my browser returns:

{"GetMessageResult":"Hello World!"}

So far so good. No problems here. A quick look at the jQuery documentation for performing a GET yields:

<html>
    <head>
        <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
        <script type="text/javascript">
            $.ajax({
                url: 'http://localhost/RestService/RestService.svc/web/GetMessage',
                type: 'GET',
                dataType: 'json',
                success: function (data) {
                    alert(data);
                },
                error: function (xhr, status, message) {
                    alert("Error: " + status + " " + message); }
                });
        </script>
    </head>
    <body>
    </body>
</html>

I run this in a small html test page using jQuery 1.72 and I get the following error:

Error: error

What gives? The error message handler that I found here gives me absolutely zero useful information. Simply put:

  • Why is my GET failing?
  • Why is the error message useless?

Solution

As it turns out, jQuery does not natively support cross-domain ajax requests as Kevin B suggested in his answer. To fix this I had to switch to using dataType: 'jsonp' and add a webHttpBinding with the crossDomainScriptEnabled property enabled:

<bindings>
  <webHttpBinding>
    <binding name="WebBindingWithScripts"
             crossDomainScriptAccessEnabled="true">
      <security mode="None" />
    </binding>
  </webHttpBinding>
</bindings>


<endpoint name="RestWeb"
          address="web"
          binding="webHttpBinding"
          behaviorConfiguration="WebEndpointBEhavior"
          bindingConfiguration="WebBindingWithScripts"
          contract="TestService.IRestService">
</endpoint>

When using only dataType: 'jsonp', you will still get errors unless you configure your WCF service to allow cross domain scripts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:27:44+00:00Added an answer on June 6, 2026 at 6:27 pm

    Are you making a cross-domain request? I see you are using localhost, but that doesn’t necessarily mean you are requesting from localhost (for all we know you could be using a different port or protocol).

    There are two reasons that the request would be failing in this case:

    1. the JSON being returned has additional characters that makes it invalid json
    2. the request is coming from a different domain than the webservice.

    I expect it to be #1 due to you not seeing the same-origin error in the console. However, since you’re getting error and not parseerror, that is unlikely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.