我想声明一个从 DataStore 获取值的全局变量,并在警报窗口中显示它的值。
var params = 1;
var storeTeacher = new Ext.data.JsonStore({
id: 'IDstoreTeacher',
url: 'school.php',
method: 'POST',
baseParams:{task: "LABEL",
parametar: params},
root: 'rows',
fields:
[{name: 'NameT', type: 'string', mapping: 'Teacher_name'}],
autoLoad: true
});
var TeacherName;
storeTeacher.load({
scope: this,
callback: function (records, operation, success) {
TeacherName = storeTeacher.getAt(0).get('NameT');
}
});
alert(TeacherName);
但是,我唯一得到的是警告窗口,上面写着:未定义