View Full Version : Problem sending an Ajax JSON proxy delete request to server.

5 Dec 2011, 10:36 AM
I am having difficulty sending an Ajax request to a remote server using JSON.
The purpose of the request is to send an 'Event' object (or preferably only its
unique id) to be deleted from a database.
I have tried using store.remove(event); - this removes event from store
but does (currently) not send request via proxy to server.

I have created a Grid Panel (Ext.grid.Panel) which has a store config,
which has the following config (a routes file and controller is also shown):

autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: 'events/list',
update: 'events/update',
}, reader: {
type: 'json'
successProperty: 'success'
writer: new Ext.data.JsonWriter()
routes file (am using java Play) with following entries:
req. method url action/method in controllers
GET /events/list Events.list
POST /events/update Events.update
In the controller I have the following actions:
public static void list() {...}
public static void update(?) {...delete event which is in parameter...}
Please can you advise on the following:
1) In order to delete the event should the api url be update or destroy?
2) what method(s) do I need to / can I call to send message to server?
3) How do I send a parameter to the update (or delete action) indicating
the event to be deleted?
4) Should the request be POST or GET?
5) I also require to send a server request to edit/update an event.

5 Dec 2011, 12:55 PM
You can execute sync() onto the store and it will batch up like method calls into one and it will send it. Or you can set autoSync on the store and it will fire off a service call for each action you take on the store.

5 Dec 2011, 3:43 PM
i recommend to get familiar with CRUD (create, read, update & destroy).
destroy is used since delete is a reserved method in many languages (like JS).

you can (but don't have to) use the rest proxy which extends the ajax proxy:

it uses:

actionMethods: {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy: 'DELETE'