I am creating a small Chrome extension that should send messages through a POST HTTP request to a server on my company network, and I use jQuery 1.4.1 to speed up the development of the javascript part.
I have this code to send a request:
function send() {
$.ajax({
url: "http://mycompany.com/update",
method: "POST",
data: {status: "sometest", in_reply_to_status_id: "anId"},
success: function(data, textStatus) {
console.log("success");
console.log(data);
console.log(textStatus);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log("error");
console.log(XMLHttpRequest);
console.log(textStatus);
console.log(errorThrown);
},
complete: function(XMLHttpRequest, textStatus) {
console.log("complete");
}
});
}
The request that was made is impossible, in the Chrome log I can see that the server is responding with an http status of 400 and with the text "These methods require POST."
If I go to the following code:
function send() {
$.post("http://sunshine.emerasoft.com/statusnet/api/statuses/update.xml", {status: "sometext", in_reply_to_status_id: "anId"}, function(data) {
console.log(data)
});
}
everything works fine, the status of http is 200, and on the server side, I see that the data that I sent is correctly saved.
$.ajax(), , , , $.post() .
- , $.ajax(), - , , , xontext Chrome?