Hi all,

I noticed there is no simple way to send synchronous requests using rails 
ujs that have a request body. At the moment there is either the possibility 
to send an AJAX request with a link like <a data-method="PUT" 
data-remote="true" data-params="data=param" …> or a synchronous request 
without a request body like this: <a data-method="DELETE">…

My proposal is to make the data-method handler check the data-params field 
and add the data that is specified there to the temporary form that is 
created in order to send the request. I already have a version of this that 
works here 
<https://github.com/sternenseemann/rails/commit/ee79a0a41cc84bc5c896e06e3437ac82d12d60e9>
.

The only downside of my implementation is that it only supports urlencoded 
form data in the data-params field currently. I want to add support for 
JSON, but I am a bit confused by the data-type field: I checked in the 
implementation of ajax() where dataType only seems to influence the 
Accept-Headers. So my question is: Is data-type intended to specify the 
type of the request or the response or both? The documentation indicates 
that it is about the type of data-type and I'd really like to use this 
field to detect the type of the data stored in data-params, since I'm not 
really fancying autodetecting that. Of course there can only be a limited 
number of supported formats since we can't send arbitrary request bodies 
using forms as opposed to using XMLHttpRequest.

I'd love to here your feedback and suggestions on this!

Cheers,

Lukas

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-core/3b38bbb0-96bc-4020-bd65-b1cbf8562d65%40googlegroups.com.

Reply via email to