Why do we have method 'PUT' in AJAX and where is it most used?
Example:
$.ajax({
url: 'script.php',
type: 'PUT',
success: function(response) {
//...
}
});
Why didn't the author simply use GET/POST instead?
For RESTful APIs POST has a specific meaning (create a resource) while PUT has a different one (update an existing resource):
However, if there's really "script.php" whoever developed it was not very thorough when creating his API. "script.php" is pretty much not RESTful at all... Usually the URL structure of a proper RESTful API looks e.g. like this:
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