View Full Version : Params Ajax request

17 Nov 2009, 5:48 AM
Hi all.

I have a panel where the user can fill a grid for each week in a year. When the user choose a different week number, the grid's store is loaded with the data of that week. The user is also able to change the grid's data for each week. I have made it so, that when the user changes the datagrid's data, and goes to another week, the changed data is stored in an array. This array is then stored in another global array with the date as the index.

When the user clicks on the button 'Save', i want to use a Ext.Ajax.request to send the changed data to the server.

The problem now is: the amount of arrays in the global array is variable, so how to send this using the 'params' property?

Mike Robinson
17 Nov 2009, 9:22 AM
You can send an arbitrarily complex structure to the host.
If the host knows how to deal with what you sent him ... :-? ... all is well.

18 Nov 2009, 12:05 AM
errr... what do you mean with an 'arbitrarily complex structure'?

18 Nov 2009, 4:07 AM
Let's say i have the columns id, firstname and lastname in the grid, and the user fills it for 3 weeks:

week 1:

array(1, "firstname1", "lastname1"),
array(2, "firstname2", "lastname2")

week 2:

array(5, "firstname4", "lastname4"),
array(6, "firstname5", "lastname5"),
array(7, "firstname6", "lastname6")

And then each week is a row(containing the grid rows) and each week is in a array named "total".

But, the amount of weeks changed is variable (is not always 2 weeks, can be 3, 4, etc), and the amount of grid rows for each week is also variable.

So, please anybody knows how to send the final array as a param with the ajax request to the server?

18 Nov 2009, 4:58 AM
You can format the data almost anyway you like.

What kind of format did you had in mind (what kind of format is the server able to handle)?

18 Nov 2009, 5:06 AM
Condor, do you mean it to parse all data in a JSON string?

18 Nov 2009, 5:18 AM
Can your server parse a JSON string? In that case you could send the data as a JSON string (use the 'jsonData' config option of Ext.Ajax.request).

If your server can't parse JSON, what kind of format would work?

18 Nov 2009, 5:38 AM
Yes, that will work thank you.

I'm just using PHP 5, so that should do.

18 Nov 2009, 5:45 AM
So you need to gather your information in an object and pass this object as 'jsonData' to the Ext.Ajax.request.