PDA

View Full Version : Ext.Ajax.request



Fallen Zen
5 Sep 2010, 11:22 AM
I have a json file with some data, I'm using this code to extract it. What's the best way to read the datalabels field from jobs_per_day?


Ext.Ajax.request({
url: 'js/RenderfarmStats/august_2010.json'
});
22241

I wish to use datalabels information in another function:


jobsPerDay.addAxis('y1', {type: 'y', labels: DATALABELS_HERE});

sosy
5 Sep 2010, 9:49 PM
Hi Zen,

if you look here, i think you will be able to find some stores which use json.

http://www.sencha.com/learn/Tutorials

Regards
Sosy

StuartAshworth
6 Sep 2010, 12:35 AM
Add a success parameter to the request call, parse the JSON result and use your value as you need.

The code below is copied pretty much exactly from the docs...



Ext.Ajax.request({
url: 'js/RenderfarmStats/august_2010.json',
success: function(response, opts) {
var obj = Ext.decode(response.responseText);

// access data labels via "obj[0].datalabels"

},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});

Stuart

Animal
6 Sep 2010, 12:37 AM
Shouldn't you be thinking in terms of Objects, and loading a Store?