It seems that using jQuery Ajax POST will pass parameters, but PUT will not. I looked at the current jQuery code and PUT and DELETE are not there. I looked at 1.4.2 jQuery and PUT and DELETE are there.
What is the workaround for passing parameters with a PUT request using the current version of jQuery?
If you look closely at the URL, we are calling the Put() action; you will find that we are passing the ID using it. Through the ajax() function we are sending the data parameter to the Put() action defined in the person controller. Here is the implementation of the Put() action within the person controller.
In the options parameter, we have specified a type option as a POST, so ajax() method will send http POST request. Also, we have specified data option as a JSON object containing data which will be submitted to the server. So this way you can send GET, POST or PUT request using ajax() method.
Can you provide an example, because put should work fine as well?
Documentation -
The type of request to make ("POST" or "GET"); the default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
Have the example in fiddle and the form parameters are passed fine (as it is put it will not be appended to url
) -
$.ajax({ url: '/echo/html/', type: 'PUT', data: "name=John&location=Boston", success: function(data) { alert('Load was performed.'); } });
Demo tested from jQuery 1.3.2 onwards on Chrome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With