just wondering how to get the json array from the store?
I want to retrieve the json array object outside the ajax request or store.
i tried this but
var arr;
var conn = new Ext.data.Connection();
conn.request({
url: listSurveyAttemptPath,
params:{survey_id:1},
success: createArray,
failure: function() {
Ext.Msg.alert('Status', 'Unable to show history at this time. Please try again later.');
}
});
function createArray(response) {
var obj = Ext.util.JSON.decode(response.responseText);
arr = obj;
alert(arr); //<-- this works!
}
alert(arr); //<-- this does not work!
the arr object inside the function createArray is correct however i cannot access it outside the function.
but i need to manipulate the arr outside the function.
else how to get the json array from the Ext.data.store?
how can i do this?
any idea?
Thanks..
arr = obj;
}
arr links to the internal obj which gets lost outside the function.
Simply try
arr = Ext.util.JSON.decode(response.responseText); Does it work now?
Anyway alert(arr) will only work, as already said, _after_ the ajax request has been done.
When you try to access it the second time, the ajax request has probably not completed.
Ajax is asynchronous. You just have to pick up your processing after the data returns.
You do get used to it!
#If you have any other info about this subject , Please add it free.# |