I’m trying to create a POST request, unfortunately the body of the POST never seems to be sent.
Below is the code that I’m using. The code is invoked when a user clicks on a link, not a form ‘submit’ button. It runs without error, invokes the servlet that is being called but, as I mentioned earlier, the body of the POST never seems to be sent.
I can validate that the request body is never sent since I have access to the servlet being called.
I’ve tried using ‘parameters’ in replace of ‘requestBody.’ I’ve also tried using a parameter string (x=a?y=b). I’ve also validated that ‘ckULK’ does contain a valid value.
Any ideas?
new Ajax.Request(sURL, { method: 'POST' , contentType: 'text/x-json' , requestBody: {ulk:ckULK} , onFailure: function(transport) { vJSONResp = transport.responseText; var JSON = eval( '(' + vJSONResp + ')' ); updateStatus(JSON.code + ': ' + JSON.message); } // End onFailure , onSuccess: function(transport) { if (200 == transport.status) { vJSONResp = transport.responseText; } else { log.value += '\n' + transport.status; } } // End onSuccess }); // End Ajax.request
These are the kind of situations where Firebug and Firefox are really helpful. I suggest you install Firebug if you don’t have it and check the request that is being sent.
You also definitely need to stick to
parametersinstead ofrequestBody.This:
Should definitely work.