View Full Version : Ext JS 4 Ajax request & load response into datastore - Help needed

27 Sep 2011, 8:19 AM
Hi All,

Im new to Ext JS & am looking into using the framework for a re-design of one of our products. Im slowly working my way into the Visual Designer and am having issues refreshing a datastore from a JSON response.

Basically i have a datastore defined in the visual desinger, and a simple form. I want the results of that ajax posted form to come back in JSON and re-populate the datastore.

I have the ajax request working fine and the repsonse seems to be valid however when trying to load it into the store I am getting the error : SCRIPT5007: Unable to get value of the property 'id': object is null or undefined

I am trying to use the dataLoad method however cant seem to make it work. Can anyone send me the right direction to refresh my datastore with the response data.

The repsonse JSON is as follows :
{ "results": [
{"id": "1", "value": "Valemount", "info": "VAL" },
{"id": "2", "value": "Vancouver", "info": "YVR" },
{"id": "3", "value": "Vanderhoof", "info": "VAN" }
] }

The full ajax request code is as follows :

var cityText = Ext.getCmp('CityText');
var f = Ext.getCmp('availSearchForm');

url : '/cgi-bin/wsLIVE/WService=wsLIVE/ajaxCityCodes.json.htm?json=true',
method: 'POST',
waitMsg: "Please wait while loading",
waitTitle: "Please wait",
params :{input:cityText.value},
success: function ( result, request ) {

//alert( result.responseText);

var jR = Ext.getCmp('jsonResponse').setValue(result.responseText );
var jsondata = Ext.decode(result.responseText);
var store = Ext.StoreMgr.get("MyJsonStore");


failure: function ( result, request ) {
var jsonData = Ext.util.JSON.decode(result.responseText);
var resultMessage = jsonData.data.result;

alert( result.resultMessage);


Any help or direction would be greatly appreciated,


28 Sep 2011, 1:14 AM
Please use CODE tags when posting code (# button on the editor toolbar).



If that doesn't work, try posting the config for your store/model/etc.

28 Sep 2011, 9:04 AM
Thanks for the info, that seems to have gotten rid of the error when loading into the store.
It seems that the records are there, however the grid attached to that datastore refreshes with what looks like the amount of rows i expected from the store, however no data is showing in the rows.

any ideas what this might be ? do I need to refresh something else ?

30 Sep 2011, 3:53 AM
Having the right number of rows is a good sign. Check that you have the right fields configured on your model or store and that the dataIndex for each grid column ties up with the field name. Remember they're case-sensitive.

If you still can't get it to work it'd help to see the relevant sections of your model, store and grid config.