[Catalyst] DELETE through REST and Jemplate

J. Shirley jshirley at gmail.com
Wed Apr 1 22:51:12 GMT 2009


On Wed, Apr 1, 2009 at 3:21 PM, Lee Aylward <lee at laylward.com> wrote:

> On Mon, Mar 30, 2009 at 04:24:42PM +0200, Emmanuel Quevillon wrote:
> > Hi,
> >
> > I am playing with REST and Jemplate from the great Tuts from JRock's
> > book.
> > However, I am facing a problem. I understand well how to retrieve
> > data from a REST url and playing Ajax with it, by a GET method.
> > However, I don't know how to change the method to DELETE from a
> > simple link like:
> >
> > test.js contains:
> >
> > function remove_item(id){
> >  Jemplate.process('test.tt2',
> >                 '[% Catalyst.uri_for("/rest/item/") %]'+id,
> >                 '#_item');
> > }
> >
> > template test.tt2:
> >
> > <a href=3D"#" onclick=3D"remove_item('[% item.id %]'); return
> > false;">Remove item</a>
> >
> > If I code my template like this, it just do a GET request.
> > How can I introduce DELETE method  to tell REST API to delete my
> > item id?
> >
>
> As has already been mentioned, you'll have to use a seperate javascript
> library to make your requests, since Jemplate only supports GET. Be
> careful when choosing a javascript library. I recently tried to use
> prototype.js to make some PUT and DELETE requests. After investigating,
> I discovered that prototype.js does not support some HTTP methods, and
> converts them to a POST with an added "_method" parameter that matches
> the method you wanted to use. I believe they do this because at some
> point not all browsers supported alternative HTTP methods over
> XMLHTTPRequest.
>
> --
> Lee Aylward
>
> _______________________________________________
>

Please do not use prototype.js.  Ever.

If you want something simple and powerful, use jQuery.

If you want a larger framework-type, use YUI or Dojo (my preference being
YUI, especially YUI3 Preview Release).


-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090401/61732=
43e/attachment.htm


More information about the Catalyst mailing list