I am trying to make a jQuery POST request from a locally hosted web-page to a locally hosted server.
My server listens at
When I send a POST request using my HTTP client, I receive a 201 created
response, as I expect.
Now, I try to send the same request using jQuery:
function postAppointment() {
$.post({
url:'http://localhost:8085/appointments',
data: appointmentFactory(),
crossDomain: true,
headers: {
'Content-Type' : 'application/json',
'Accept' : 'application/json'
}
});
}
I receive the following error message from the Safari error console:
[Error] Failed to load resource: the server responded with a status of 501 (Not Implemented) ([object Object], line 0)
However, I'm not so sure the server is actually responding, because I have tried sending the requests to netcat
and it is not printing out any requests, while if I use my GUI HTTP client, netcat
does print out the requests.
So... to me this seems to be a client-side issue, since my backend-service is confirmed to be working by my GUI HTTP client. I thought maybe this problem has to do with how I am serving my page, so I have tried serving the page:
- Opening directly from the Finder
- Opening via IDE link which seems to run a server (JetBrains WebStorm)
python -m SimpleHTTPServer
Is there a client-side configuration I am missing which is preventing me from sending a request?
Thanks for any help.
And in case you are wondering, appointmentFactory()
returns
Object
eventName: "Fiesta Forever"
phoneNumber: "13125555555"
time: Thu Dec 18 2014 17:15:00 GMT-0600 (CST)
__proto__: Object
And I have also sent the request by parsing the object with JSON.stringify()
.... I'm not sure if that is done automatically.
I also tried the request via Desktop Chrome, and received the following additional information:
Thanks again for any help.
-Blake