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 7028991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:28:45+00:00 2026-05-28T00:28:45+00:00

I have a JSON WCF service and I have written some javascript to access

  • 0

I have a JSON WCF service and I have written some javascript to access the service like this,

function stuffClick2() {
        $.ajax({
            url: "http://192.168.54.98/JsonWCFService/Service1.svc/Post",
            type: "POST",
            contentType: "application/json",
            data: '{"x":"1","y":"2","message":"The answer is: "}',
            dataType: "html",
            success: function(data) { $('body').html(data); }     
        });
    }

I have written an HTML page which has the above javascript in it. The HTML page is served up using IIS.

When I access the HTML page using chrome on my PC I see these operations being sent to the WCF JSON service in this order,

OPTIONS /JsonWCFService/Service1.svc/Post HTTP/1.1
POST /JsonWCFService/Service1.svc/Post HTTP/1.1

The OPTIONS was previously failing, but I made the OPTIONS call return this header which then makes it work,

Access-Control-Allow-Origin: *

But the callback I have defined above does not work,

success: function(data) { $('body').html(data); } 

I know that the WCF service has returned something like this,

<b> The answer is 3 </b>

But when the callback is called the value of data is an empty string.

When I run the html page in a different browser (IE) which only causes a POST call, but not an OPTIONS call then it works. I notice that IE warns me that it poses a security risk and asks me whether I want to continue.

  • 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-05-28T00:28:46+00:00Added an answer on May 28, 2026 at 12:28 am

    I ran across this issue when I was trying to implement CORS with WCF for a mobile HTML app I was making. OPTIONS is a preflight request to see if a method is available before calling it.

    Here will be your problems:

    1. OPTIONS is, I think, defaultly turned off by IIS. Possibly a starting point is here: http://www-jo.se/f.pfleger/cors-and-iis
    2. The OPTIONS verb will make it to your actual POST method so you will want to have something in WCF filter OPTIONS to another method with the same return type that does nothing. And filter the POST verb to your actual method. If you don’t do this, you will find strange behavior of either your method being called twice or it will throw a webservice vague exception.

    Im not sure if you are using CORS or not, but the principal will be the same, as it sends a OPTIONS request then a POST request.

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

Sidebar

Related Questions

I have a WCF service that I access fram Javascript using AJAX and JSON.
I have some JSON returned to the browser like this product: { Title: School
I have a WCF service which I would like to product XML and JSON
I have been having some issues retrieving JSON data from a WCF service application
I have a WCF service in an ASP.NET AJAX app that is returning json.
I have a simple resftul wcf service. The .svc file looks like this <%@
My AJAX-enabled WCF service returns JSON using this contract, [DataContract] public class JQGridContract {
I have a RESTful WCF service with a method declared like this: [OperationContract(Name =
I have a WCF service that returns JSON to the clients. This is the
I have a simple WCF service setup that uses JSON. In this service I

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.