Cyberangel67
4 Aug 2007, 5:37 PM
Ajax not working properly, do not know why?
The following code when dumping the myData variable is showing undefined, and I can't see why, and yes the json data is formatted correctly, as I use that function elsewhere.
var flightsGrid = {
init : function(){
var myData;
function doJSON(stringData) {
myData = Ext.util.JSON.decode(stringData);
}
Ext.Ajax.request({
url : 'http://localhost/mydata.php' ,
params : { action : 'getComponents' },
method: 'get',
success: function ( result, request ) {
doJSON(result.responseText);
},
failure: function ( result, request) {
Ext.MessageBox.alert('Failed', 'There was a problem retrieving the data from the server. The server or network may not have been available at the time of your request. Please try again.'+action.date);
}
});
console.log(myData);
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(myData),
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty: 'totalCount',
id: 'id'
},
[
{name: 'post_id'},
{name: 'topic_title'},
{name: 'author'},
{name: 'reply_count'}
])
});
// create the editor grid
var grid = new Ext.grid.Grid('flights-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:false,
loadMask: true,
enableDragDrop:true,
autoExpandColumn: 'id'
});
var layout = Ext.BorderLayout.create({
center: {
margins:{left:0,top:0,right:0,bottom:0},
panels: [new Ext.GridPanel(grid)]
}
}, 'grid-panel');
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
ds.load({params:{start:0, limit:25}});
}
};
Ext.onReady(flightsGrid.init, flightsGrid, true);
The following code when dumping the myData variable is showing undefined, and I can't see why, and yes the json data is formatted correctly, as I use that function elsewhere.
var flightsGrid = {
init : function(){
var myData;
function doJSON(stringData) {
myData = Ext.util.JSON.decode(stringData);
}
Ext.Ajax.request({
url : 'http://localhost/mydata.php' ,
params : { action : 'getComponents' },
method: 'get',
success: function ( result, request ) {
doJSON(result.responseText);
},
failure: function ( result, request) {
Ext.MessageBox.alert('Failed', 'There was a problem retrieving the data from the server. The server or network may not have been available at the time of your request. Please try again.'+action.date);
}
});
console.log(myData);
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(myData),
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty: 'totalCount',
id: 'id'
},
[
{name: 'post_id'},
{name: 'topic_title'},
{name: 'author'},
{name: 'reply_count'}
])
});
// create the editor grid
var grid = new Ext.grid.Grid('flights-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:false,
loadMask: true,
enableDragDrop:true,
autoExpandColumn: 'id'
});
var layout = Ext.BorderLayout.create({
center: {
margins:{left:0,top:0,right:0,bottom:0},
panels: [new Ext.GridPanel(grid)]
}
}, 'grid-panel');
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
ds.load({params:{start:0, limit:25}});
}
};
Ext.onReady(flightsGrid.init, flightsGrid, true);