-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AJAX acceleration does not support PUT HTTP method (only sends a POST) #51
Comments
Basically, browsers didn't (and might still) not support anything other than GET/POST (not including HEAD and OPTIONS). To work around this, Ruby on Rails started adding a Unpoly works in the same way - the actual request is a POST, but with If you're using Rack or something based off it, there is a |
Ah, I didn't realize this was a layover from Rails. However, browsers limiting themselves to GET/POST is only applicable to HTML forms. This is an AJAX request, so it is presumably using XMLHttpRequest under the hood, which does support the PUT method. More to the point, jQuery's |
Yes , it was form specific. The original premise was that without Javascript, people still expected forms to submit correctly (ala, the original Since Unpoly wouldn't be used without Javascript enabled, I agree that Unpoly should use the native method where possible. But looking at the source code, it looks like this is already the case, except Unpoly makes the decision to wrap non-GET/POST methods into a POST, as you're seeing. You just need to tell Unpoly not to wrap them in a POST. Spitballing here, but you could try this: up.proxy.config.wrapMethods = [] |
Ah, I looked into the source enough to realize that methods were being wrapped, but not closely enough to see that solution. It worked perfectly, thank you @adam12! |
Also note that while many browsers now support verbs like That's another reason why many frameworks like Rails, Symfony and Express offer a way to wrap the verb in a |
As far as I can tell,
up.request(..., {method: 'PUT'})
sends a POST request instead of the desired PUT request, making the distinct handling of PUT/POST in our REST backend useless.Is there a reason for this? Am I missing something obvious?
The text was updated successfully, but these errors were encountered: