I have a Web API which I am calling using the JQuery ajax function. When I test the service directly (using the Chrome RESTEasy extension) it works fine, however when I call it using the JQuery ajax function I get an error. I'm calling it on port 81:

$.ajax({
   url: "http://127.0.0.1:81/api/people",
  data: JSON.stringify(personToCreate),
  type: "POST",
  contentType: "application/json;charset=utf-8",
  statusCode: {
     201: function (newPerson) {
        callback(newPerson);
     }
  },
  success: function (newPerson) {
     alert("New person created with an Id of " + newPerson.Id);
  },
  error: function (jqXHR, textStatus, errorThrown) {
     alert('Error. '+textStatus+'. '+errorThrown);
  }
});

...but when I trace it using FireBug Lite the response comes from port 82:

{"Message":"No HTTP resource was found that matches the request URI 'http://127.0.0.1:82/api/people'.","MessageDetail":"No action was found on the controller 'People' that matches the request."}

I think the error is, effectively, due to cross-site scripting being blocked, but I'm not actually cross-site scripting, if you see what I mean.

Has anyone else come across this and been able to fix it?

share|improve this question

25% accept rate
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.