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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:16:02+00:00 2026-06-10T13:16:02+00:00

Am trying to post json data to the server. am using visual studio 2012

  • 0

Am trying to post json data to the server. am using visual studio 2012 RC and windowsazure for hosting the web application . On posting am getting the following errors :

  1. OPTIONS http://*.azurewebsites.net/api/Child 405 (Method Not Allowed) jquery-1.7.1.js:8102

  2. XMLHttpRequest cannot load http://*.azurewebsites.net/api/Child. Origin null is not allowed by Access-Control-Allow-Origin.

My client side code is :

       function PostChild() {                  
        var Chld = {};            
        Chld.Child_FirstName = $("#Child_FirstName").val();
        Chld.Child_LastName = $("#Child_LastName").val();
        Chld.Child_Age = $("#Child_Age").val();          
        var createurl = "http://*.azurewebsites.net/api/Child";                      
        $.ajax({
            type: "POST",
            url: createurl,
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(Chld),       
            statusCode: {
                200: function () {
                    $("#txtmsg").val("done");
                    alert('Success');
                }
            },
            error:
                function (res) {
                    alert('Error');
                    $("#txtmsg").val("error" + " "
                    + res.status + " " + res.statusText);
                }
        });
    }

My server side code is :

    public HttpResponseMessage PostChild(Child child)
    {


        if (ModelState.IsValid)
        {
            db.Children.Add(child);
            db.SaveChanges();

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, child);
            response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = child.ChildID }));
            return response;
        }
        else
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
    }

Help me please

Thanks,

  • 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-10T13:16:04+00:00Added an answer on June 10, 2026 at 1:16 pm

    The errors was due to CORS (Cross Origin Resource sharing). By default, a web page cannot make calls to services (APIs) on a domain other than the one where the page came from. This is a security measure to avoid cross-site forgery attacks and all.

    To solve it follow this tutorial:

    http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx

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

Sidebar

Related Questions

using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studios.R2.Express; What I'm trying to do, is get a button to
I am trying to post data to my server (vb.net) using mobile devices. I've
I am trying to send data, in json format to my webservice, using POST.
Trying to post JSON data to Spring controller.. Not working at all JSP Code:
I am trying to post a URL to the server using the Asynchronous type
I am trying to mock the server response for a POST request using Sinon.js.
I'm trying to post some very simple data to a php file using jquery
I ve been trying to post something using ajax but I m getting a
I am using jQuery to get back some JSON data from the server. I
I'm trying to send the node instance JSON data using an ajax get request

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.