0
我有簡單的代碼:正確設置全局變量從JavaScript
<script type="text/javascript">
var dataFromBrowser;
var dataForStore = [];
var callServerOwnerId = {
callback:callbackFunction,
arg: dataFromBrowser
};
// call to DWR function - from Java
AssetScreener.getEntityOwnerIds(callServerOwnerId);
function callbackFunction(dataFromServer, arg1) {
// yes, I see what I need
alert(dataFromServer);
return dataForStore[0] = dataFromServer[0];
}
console.log(dataForStore);
的問題是,我需要從我的callbackFunction
檢索數據和數據設置爲dataForStore
?
你不需要「返回」,只需dataForStore [0] = dataFromServer [0] – Adam