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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:41:10+00:00 2026-06-08T15:41:10+00:00

I am facing an error when calling a WCF method from jQuery. The call

  • 0

I am facing an error when calling a WCF method from jQuery.
The call returns just fine when I implement it on localhost but throws an access denied error when the service is hosted on a separate server.

Here are the steps to reproduce the error:-

  1. Run the project locally and check if the service is running
    e.g.:http://localhost:3369/AppsterWcfService.svc/DoWork

  2. Create a test client (test.html) page locally and run this project.
    When clicked on the login button it works fine.

  3. Now host the service on a remote server and replace the url with the new url i.e. url of the hosted service.

  4. Now run the test.html page, click on the button. Here I get access denied error.

I have tried various methods of accessing the server e.g.:-

  1. By using MVC
  2. Handler
  3. simple .aspx page
  4. Adding different parameters in the jquery ajax call and web.config file.
  5. given different permissions in iis. like network service, iuser, anonymous, guest etc.

I suppose it is some kind of cross-domain related issue with jQuery.
Any help will be appreciated.

Thanks,
-Sumit

  • 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-08T15:41:13+00:00Added an answer on June 8, 2026 at 3:41 pm

    For you to consume a cross domain WCF REST service using jQuery please find a sample below:

    My Service looks as below:

        [ServiceContract]
        public interface IJSONPService
        {
            [OperationContract]
            [WebGet]
            string GetDate();
    
            [OperationContract]
            [WebInvoke]
            string PostData(string name);
        }
    

    Now my config entries for the above service looks as shown:

    <services>
        <service name="Service.JSONPService">
            <endpoint address="" binding="webHttpBinding" behaviorConfiguration="json" bindingConfiguration="defaultRestJsonp" contract="Service.IJSONPService">
            </endpoint>
        </service>
    </services>
    <behaviors>
          <endpointBehaviors>
             <behavior name="json">
                 <enableWebScript />
             </behavior>
       </behaviors>
    </endpointBehaviors>
    <webHttpBinding>
            <binding name="defaultRestJsonp" crossDomainScriptAccessEnabled="true">
              <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" />
              <security mode="None" />
            </binding>
    </webHttpBinding>
    

    You need to note the crossDomainScriptAccessEnabled attribute in the binding element “defaultRestJsonp” which takes care of determining the request to be for JSONP and appropriately converting the response to be wrapped in the callback method from the URL which comes as a query string

    Now from your page do the below JavaScript that calls the above WCF REST service as shown:

    function TestingWCFRestWithJsonp() {
                    $.ajax({
                        url: "http://domain.com/Service/JSONPService.svc/GetDate",
                        dataType: "jsonp",
                        type: "GET",
                        timeout: 10000,
                        jsonpCallback: "MyCallback",
                        success: function (data, textStatus, jqXHR) {
                            alert(data);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {alert('error');
    
                        },
                        complete: function (jqXHR, textStatus) {alert('complete');
                        }
                    });
                }
                function MyCallback(data) {
                    alert(data);
                }
    

    Check out the jsonpCallback property in the $.ajax method call.

    The raw request to the web service call looks as below:

    GET http://localhost/Service/JSONPService.svc/GetDate?callback=MyCallback&_=1343391683779 HTTP/1.1
    Host: localhost
    Connection: keep-alive
    

    And the raw response from the WCF REST service looks as below:

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: application/x-javascript
    Date: Fri, 27 Jul 2012 12:21:23 GMT
    Content-Length: 27
    
    MyCallback("27\/07\/2012");
    

    NOTE: When you perform a JSONP request your $.ajax methods error/complete/success are not called.

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

Sidebar

Related Questions

I'm trying to run the following code but unfortunately facing Error problems package jskypeexample;
i am facing an error in Jquery Load function. I am using jquery to
I am facing a problem while calling processRequest function from javascript. I need two
Yesterday my project was running smoothly but today I'm facing an error. Here are
I am facing an issue where I have one method which is calling another
i am able to parse the XML file. but i am facing strange error.
today i was facing a strange problem: got a 'missing method' error on a
I just cloned the example project geb-grails-example and facing an error related to Spock.
I am facing error C2065: 'IOCTL_NDISUIO_OPEN_DEVICE' : undeclared identifier error in beneath code. Where
I am facing an error while binding the service with interface stub() . Here

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.