View Full Version : Newbie question about JSON and sending HTTP requests

2 Feb 2010, 11:06 AM

If I have a data grid and I'm using a form to add a new record, what is the best way to program this so that when the user hits the "submit" button, the form's fields are bundled up into a JSON message and POSTed to the server?

Also, what is the best way to add a default set of parameters to the requests such as a session id?


2 Feb 2010, 7:35 PM
you can grab the dirty data from the store grid.getStore().getModifiedRecords() then Ext.encode() the value into the params of a POST'd Ext.Ajax.request call, all triggered by the handler on the button...

... or just use the writer object... ;-)

3 Feb 2010, 4:03 AM
ds.on('add', function(store, record, op) {
saveChanges(store, record);

ds.on('update', function(store, record, op) {
saveChanges(store, record);

function saveChanges(store, record) {
//Do what ever

Mike Robinson
3 Feb 2010, 3:24 PM
Use a "Writer" object in association with your "Store" object. When you do this, the Store becomes capable of handling a full range of CRUD requests. The Store issues the Ajax requests automatically, and handles the response.

You simply make the necessary requests to the Store object. The stream of host requests is determined, generated, and handled automagically.