No 'Access-Control-Allow-Origin' header is present on the requested resource

Posted by Vuyiswamb under ASP.NET AJAX on 1/30/2014 | Points: 10 | Views : 42849 | Status : [Member] [MVP] [Administrator] | Replies : 1
Good Day

i have a web api that i want to call on the client side and return its contents, so it s a post and i return some string. Now i have a form that will have the data to be posted as depicted below

    <form name="registrationForm"    method="post">

and there are other controls within the form and i have a button that triggers the post as depicted below

<input title="Register" onclick="ProcessRegistration();" style="width: 100px; height: 100px; align-self: center" type="submit" name="submit_fourth" id="submit1" value="register" />

onCick i call a function from the client side, the definition of the function is

     function ProcessRegistration()

$.getJSON("", function (data) {



now when i click the button to fire the service i get the following error in the console

XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:46506' is therefore not allowed access. 

Does anyone know how to solve this ?


Thank you for posting at Dotnetfunda


Posted by: kgovindarao523-21772 on: 1/31/2014 [Member] [MVP] Bronze | Points: 25

Try like this.

type: "POST",
url: "",
contentType: "application/json; charset=utf-8",
data: oEmployee,// if Data should complex type,then pass object here, else null
dataType: "json",
success: function (obj)
alert(obj);// Do manipulations here
error: function (result)
alert("POST Method, Error in binding....... ");

Thank you,

Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response