View Full Version : Using HTTP DELETE or PUT methods with Ext.data.Connection or Ext.ajax.request

Virtual Ark
15 Jan 2011, 4:54 PM
Hi there,

I've been using the ExtJs 3.3.1 framework for a few months now with Rails 3.0.3 for the server back-end. I've found myself using the Ext.ajax.request method to make various one off ajax calls which don't really fit into a data store.

After many hours of trial and error, and finally reading the API doco properly :) I found that you can't use HTTP DELETE or PUT as methods when using Ext.ajax.request, only POST and GET.

Is there another low level (Ext.ajax.request level) ExtJs way to make one off restful requests which include the HTTP DELETE and PUT methods?



15 Jan 2011, 9:44 PM
you want to delete some records (on the server) by a command from the Ext Js (client browser side) ?
If so, IS NEVER HEALTY to do this !
You must pass it by get or post to the server... maybe they take one month over internet until arrive on the eerver. you don't know... and maybe in this time, data is already changed no the server by another user...
And Ajax is good to for retrieve data from server, on the client... But not really nice for commanding changes onto a database...
I made lot of web apps, but in Ext I am a rookie...
But there are some gurus on Ext on this forum... I am sure someone will give you some voodoo deep Ext calls for your needs...

Virtual Ark
15 Jan 2011, 11:11 PM
I've just found another thread which states the Ext.ajax.request method supports DELETE and PUT methods:-


I'm going to do some more tests to confirm.

When I originally tested this I found the requests were being submitted as POST even after specifying DELETE in the method attribute. I *think* this was due to me specifying values in the baseParams attribute. I'll post my results later.

16 Jan 2011, 5:16 AM
Ext.data.Connection supports method:'PUT' and 'DELETE'. You must have used it wrong (and yes, you should specify 'method' in options and not in baseParams).

16 Jan 2011, 12:08 PM
Where did you read in the API manual that you can't use HTTP DELETE or PUT as methods when using Ext.ajax.request?

Virtual Ark
16 Jan 2011, 3:19 PM
Thanks for the confirmation on this guys, appreciate the responses.

@devtig - I misinterpreted the the doco. If you check out the Ext.Ajax page under the API doco, specifically the method attribute. It states:-

(defaults to undefined; if not set but params are present will use "POST", otherwise will use "GET".)

So thats referring to defaults if nothing is set.

@Condor - Yes I agree, must have done something wrong. I'm creating a test in isolation from my project to get this working, rule out any issues.

One again thanks for the repsonses.



Virtual Ark
9 Feb 2011, 8:03 PM
Its been a while but I finally got around to looking into this more. After some discussion with a Rails ninja I have been schooled in the ways of doing PUT and DELETE request from browsers, using the _method parameter.

In general web browsers don't support making HTTP PUT and DELETE request directly, so instead simulate them but sending _method=PUT|DELETE in a POST request. Ruby on Rails understands this parameter and sends the request along to the appropriate actions without the need to set up custom routes. Beautiful :)

RESTification for the win!