I was just reading this article on Prototype 1.5 and a couple of
things caught my eye that related to recent conversations here on this
list.
http://www.xml.com/pub/a/2007/01/24/whats-new-in-prototype-15.html
Of the many new features and enhancements was this one:
"The 1.5 release adds even more power [to Ajax development],
especially as relates to creating RESTful, HTTP-embracing requests."
The Rails community heavily influenced this release of Prototype and,
as I had mention, Rails 1.2 makes REST a convention to how apps are
built.
Here is the most interesting point under REST support for us here:
---
The standard XMLHttpRequest object at the heart of Ajax functionality
only allows HTTP GET and POST methods, but RESTfully-designed web
applications often call for the lesser-used methods, like PUT and
DELETE. Until browsers support the full range of HTTP methods,
Prototype offers a compromise: "tunneling" those methods over POST, by
including a _method query parameter with the request. You can now
specify the intended HTTP method with the method option on all Ajax
functions (the default is POST). Methods other than GET or POST will
actually be requested with POST, but will have a _method query
parameter appended to the request URL. For example:
// Creates a POST request to /feeds/1.rss?_method=PUT
new Ajax.Request('/feeds/1.rss', { method:'put', postBody:myXML,
contentType:'application/rss+xml' });
Of course, the server side of the application must be written to
understand this convention as well, but if you use Rails, you'll get
the behavior for free.
----
The issue of browsers supporting PUT and DELETE came up in our
discussion so its worth noting how that community workaround the issue
in a "standard" way. More importantly, I'm thinking that the newly
REST-enabled CGI::Application::Dispatch should natively support this
same tunneling convention.
Thoughts?
<tim/>
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.