View Full Version : How to send JSON data to variable from Ext.Ajax.request?

28 Apr 2012, 2:13 AM
Hello everyone.

I want to get data in JSON format, parse them to variable and use it variable later.

I'm trying something like this:

var fruitDisplay;
url: me.initialConfig.baseAppUrl + "Shop/Fruits/LoadAjax/",
params: {
'loadDto.Fruit.Id': fruitSelect.lastSelectedValue,
'loadDto.Shelf.Id': me.initialConfig.moduleShelfId
method: 'POST',
success: function (x) {
var productData = JSON.parse(x.response.responseText);
fruitDisplay = productData;
failure: function (x) { //TODO

But I've got two problems which I can't solve :( The first is that to fruitDisplay is sent Object and the second is that JSON.Parse sends exception Cannot read property "responseText" or undefined. The Ajax request works perfectly, I've got all requested data in response.
Does anybody know which mistakes I made?

28 Apr 2012, 3:07 AM
Problem was solved.
First I should decode response to Object by Ext.decode and use x.responseText then if I want clear data I should use Ext.encode to get them.