simonr26
5 Dec 2011, 10:36 AM
Hello,
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.
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.