Javascript Jquery回调参数
不确定我在这里做错了什么,但让我来设置场景 开始时,存储区(resultsStore)将填充数据并通过函数调用显示 现在,需要通过另一个存储获取更多数据并将这两个集合传递给原始函数的中间步骤 我已经尝试了下面的许多变体,但这两个数据集似乎没有传递给updateLeftPanel函数,第一个数据集很好,第二个数据集表示“未定义”。我有什么明显的遗漏吗Javascript Jquery回调参数,javascript,jquery,extjs,Javascript,Jquery,Extjs,不确定我在这里做错了什么,但让我来设置场景 开始时,存储区(resultsStore)将填充数据并通过函数调用显示 现在,需要通过另一个存储获取更多数据并将这两个集合传递给原始函数的中间步骤 我已经尝试了下面的许多变体,但这两个数据集似乎没有传递给updateLeftPanel函数,第一个数据集很好,第二个数据集表示“未定义”。我有什么明显的遗漏吗 resultsStore.load({ params: { 'certid' : certId }, cal
resultsStore.load({
params: {
'certid' : certId
},
callback: function(record,operation,success){
updateRightPanel(record[0].data); // code not shown,works fine
//updateLeftPanel(record[0].data); // original call
loadCriteriaStore(record[0].data); // new call
}
});
function loadCriteriaStore(data)
{
criteriaStore.load({
params: {
'edition' : data['Edition']
},
callback: function(record,operation,success,data){
updateLeftPanel(data,record[0].data);
// orig data first, new dataset second
}
});
}
function updateLeftPanel(data, dataa){
// code here
dataa object still unpopulated
}
在
loadCriteriaStore
函数的回调中,您将分配4个参数。我假设它只通过3级
因此,在该回调中,包含数据的数据
被一个新的“本地”数据
覆盖,即未定义
function loadCriteriaStore(data)
{
criteriaStore.load({
params: {
'edition' : data['Edition']
},
// Get rid of the ",data" here
callback: function(record,operation,success){
// the `data` param will be the value passed to `loadCriteriaStore`
updateLeftPanel(data,record[0].data);
// orig data first, new dataset second
}
});
}
我相信这是有效的,只是目前还有其他问题,但我想说声谢谢。将尝试回复更新。不客气。如果您还有其他问题,请随时更新问题。更新:看起来在updateLeftPanel中,第二组数据仍然不存在。但是在firefox调试器中,我可以看到从获取过程中返回和填充的数据。如果在
updateLeftPanel
之前使用console.log(记录[0])
会发生什么?我的问题因我的JSON构建技能而更加复杂:)答案是正确的,再次感谢!