I have created a REST
service and i tested it on Chrome REST Console
. There its working fine and i am getting the response but while consuming the same by jquery Ajax i am getting "NetworkError: 405 Method Not Allowed error in Ajax Call
and Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:64132/Auth. (Reason: CORS request failed).
error.Here is my Ajax code..
var UserDetails = { "UserName": "Bond", "Password": "password" };
$.ajax({
type: 'POST',
url: 'http://localhost:64132/Auth',
crossDomain: true,
data: UserDetails,
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.UserName);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("some error");
}
});
Please help me to correct this and successfully call the Service.Thanks..
Update
when i am trying to call the Service from Chrome i am getting following error in console..
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
Test.html:1 XMLHttpRequest cannot load http://localhost:64132/Auth. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 405.