I have the simple code:
<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);
The problem is that I need to retrieve data from my callbackFunction and set data to dataForStore ?
In javascript setting a global variable is as simple as ommitting the var keyword.
For example:
Will produce undefined while
Will produce 6. Note that generally speaking (there are of course exceptions), if you’re using global variables you’re doing it wrong.