javascript - jQuery.ajax() sends POST requests as GET in a Chrome extension -
I am creating a small chrome extension that messages a server in my company network via POST http request Send me, and I'm using jQuery 1.4.1 to speed up the development of the JavaScript part.
I have this code to send a request:
send function () {$ .ajax ({url: "http://mycompany.com/update" , Method: "post", data: {status: "sometest", in_reply_to_status_id: "anId"}, success: work (data, text position) {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 ("full");}}); }
The request made in this way fails, in the Chrome log I see that the server responds with HTTP status 400 and "this method requires POST" .
If I make the above code change with it:
send the function () {$ .post ("http://sunshine.emerasoft.com/statusnet/ Api / statuses / update.xml ", {status:" some time ago ", in_reply_to_status_id:" anId "}, function (data) {console.log (data)}); }
Everything works fine, http is 200 and I can see on the server that the data I've sent has been saved properly.
Get me full $ The need to use the Ajax () method because I need to do some work in case of success or failure, and some other when the request is complete, then $ .post () is not enough. Am I doing something wrong $ .ajax (), or is there an issue of some kind, maybe because I'm in the XText extension?
Thanks
I believe the function takes the 'type' option , Not a 'method' option.
The default type is GET.
Comments
Post a Comment