I have a number of helper functions on my website to process forms and submit to a web service running on another system. Despite changing method types, I can't get the requests to go through as POST, or PUT. I'm sure I've set the option correct, but nothing has changed.
- function sendRequest(path, requestMethod, parameters, callback) {
- var requestURL = serverBaseURL + path;
-
- console.log("Sending request to "+requestURL);
- console.log(parameters);
-
- var requestSettings = {
- type: requestMethod,
- data: parameters,
- success: callback,
- dataType: "jsonp",
- error: function(e) {
- console.log("Request error: "+e);
- }
- }
-
- console.log(requestSettings);
- $.ajax(requestURL, requestSettings);
- }
- function sendPOSTRequest(path, parameters, callback) {
- sendRequest(path, "POST", parameters, callback);
- }
the parameter "parameters" is a JSON object -> { lastname: "last", firstname: "first"} and callback is an anonymous function. I think the problem is something to do with the way jQuery is encoding the data, perhaps it's not compatible with sending POST messages. Any suggestions?