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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:19:04+00:00 2026-06-05T02:19:04+00:00

I have the following web service created and using the latest version of jquery

  • 0

I have the following web service created and using the latest version of jquery I need to post to the web service.

I can not figure this out. I’ve read that JSONP won’t work with a POST. How do I get this to work?

I need to do a cross domain post using jQuery to WCF.

service.cs:

namespace AjaxPost
{
    [DataContractAttribute]
    public class Message
    {
      [DataMemberAttribute]
      public string success;

      public Message(string success)
        this.success = success;
    }


    [ServiceContract(Namespace="JsonpAjaxService")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class User
    {
        [WebInvoke(ResponseFormat = WebMessageFormat.Json, Method="POST")]
        public Message CreateUser(string email, string username, string password, string phone, string image)
        {
           Message msg = new Message("true");
           return msg;
        }
    }
}

service.svc:

<%@ServiceHost 
  language="c#"
  Debug="true"
  Service="Microsoft.Samples.Jsonp.CustomerService"
  Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" 
%>

Service Web.Config:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
  <httpProtocol>
      <customHeaders>
          <add name="Access-Control-Allow-Origin" value="*" />
          <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE" />
      </customHeaders>
  </httpProtocol>
</system.webServer>

<system.serviceModel>        
    <behaviors>
        <serviceBehaviors>
            <behavior name="MetadataBehavior">
                <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
                <serviceMetadata httpGetEnabled="True"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
        <webScriptEndpoint>
            <standardEndpoint name="" crossDomainScriptAccessEnabled="true"/>
        </webScriptEndpoint>
    </standardEndpoints>
</system.serviceModel>

index.html

    wcfServiceUrl = "http://localhost:33695/Service.svc/CreateUser";

    $.ajax({
        crossDomain: true,
        cache: true,
        url: wcfServiceUrl,
        data: "{}",
        type: "POST",
        jsonpCallback: "Message",
        contentType: "application/json",
        dataType: "json",
        data: "{ \"myusername\": \"mypassword\" }",
        error: function (request, status, error) {
            //error loading data
            alert("error");
        },
        success: function (menu) {
            alert('success');
        }
    });
  • 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-05T02:19:06+00:00Added an answer on June 5, 2026 at 2:19 am

    I found a solution using CORS (HTML 5 Solution)
    http://code.msdn.microsoft.com/windowsdesktop/Implementing-CORS-support-c1f9cd4b

    If anyone knows a working solution that does not use CORS (HTML 5) that would be awesome. Correct me if i’m wrong but, CORS requires HTML 5 supported browsers and I prefer a solution that is not reliant on a HTML 5 browser.

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

Sidebar

Related Questions

I have a web service created using Apache CXF, and two .NET clients using
I have created a C# web service using visual studio to stop the windows
I have created application which is accessing alfresco using web service client. Now I
Hi guys i have this code to be created as a web service, the
I have a web service, created using C#. For some reason, it seems to
We have created a web service using JAX-WS and ProSyst OSGi. Accessing the service
I have created a web service using Microsoft C# and i was able to
I have the following JSON coming back from a web service which I am
I have a basic web service that returns the following object as JSON: public
I am using IIS V5.1. Integrated windows authentication I have a following web config:

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.