I'm making requests from a page served on localhost
to a server I have hosted on a VPS. I had issues making GET
requests and found that I had to enable CORS on the server, which worked. Now I'm trying to making POST
requests, but I'm running into the same issue I did with the GET
s. I get back
{'readyState': 0, 'status': 0, "statusText": "error"}
The request i'm sending:
var story = $("#post_story").val();
var title = $("#title").val();
var url = BASE_URL + "/stories";
var data = {
content: story,
title: title,
category: "some_cat"
};
$.ajax({
url: url,
crossDomain: true,
type: "POST",
dataType: "json",
contentType: "application/json",
data: data,
success: (function (data, status) {
console.log(data);
$("#post_story").text("");
$("#title").text("");
}),
error: (function (xhr, status, err) {
console.log(status);
console.log(error);
console.log(xhr);
})
});
I'm using tshark on the server and it doesn't show anything incoming.
If I change json
to jsonp
, tshark shows:
GET /stories?callback=jQuery1102020064887526511765_1385831485614&content=somewords&title=sometitle&category=some_cat&_=1385831485615 HTTP/1.1
but on the client I get a 500 Internal server error