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

  • SEARCH
  • Home
  • 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 7573257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:08:13+00:00 2026-05-30T16:08:13+00:00

I have a WCF Service which returns a string. I am trying to call

  • 0

I have a WCF Service which returns a string. I am trying to call it using a cross domain JsonP request. This is working in IE but no other browser. I get a parser error back in Firefox and Chrome.

From reading through various articles i seem to think that maybe the service needs to be returning the result back as a different format. Any ideas would be helpful, here is my code.

WCF Service Code

[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
public string SponsorLayout2(string projectScope, int projectYear, int imageHeight)
{
   // Mock data
   projectScope = "uk";
   projectYear = 2012;
   imageHeight = 42;

   // Get projectId
   var project = Projects.GetProjectByProjectScopeAndYear(projectScope, projectYear);

   // Get project sponsor layouts
   var projectSponsorLayout = ProjectSponsorLayouts.GetProjectSponsorLayout(project.Id, imageHeight);

   // Return the sponsors
   if (projectSponsorLayout != null)
      return projectSponsorLayout.Body;

      return null;

}

Jquery Ajax Call

$.ajax({
cache: false,
type: "GET",
async: false,
data: {},
url: "http://127.0.0.1:8082/HtmlService.svc/SponsorLayout2",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
crossDomain: true,          
success: function (data) {  
    alert("success");       
},
error: function (xhr) {
          alert("error");
    alert(xhr.statusText);
},
complete: function(jqXHR, textStatus) {     
          alert(textStatus); 
      } 
});
  • 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-30T16:08:14+00:00Added an answer on May 30, 2026 at 4:08 pm

    I found out why I was getting the problem stated above and thought I would share this with you.
    For some reason there was a conflict between this attribute

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    

    which sits on top of my class

    public class MyClass
    

    and this rule in my web.config file

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    

    I have ended up commenting the rule out in my web.config and everything come to life. Because my service is an AJAX ready service, the attribute is added above the class out of the box. Anyway this worked for me and hope it helps anyone else in the same situation.

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

Sidebar

Related Questions

I have a WCF-REST service with one method which returns a string: [ServiceContract] public
I have a WCF service which accepts a string as a paramter for one
I have a quite simple WCF service method which returns an IQueryable, just for
I am designing a WCF service using DDD. I have a domain service layer
I have created a WCF service which returns IEnumerable<CyberResourceProvisioningAction> . The CyberResourceProvisioningAction type has
I have a WCF service which I am trying to use to generate an
I'm trying to implement a REST service using WCF which will take the parameters
I have an Operation Contract in my WCF service which returns an instance of
I have a WCF service which will be hosted under IIS. Now I have
I have a WCF service which works on my dev machine running IIS 7,

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.