19.05.2017, 08:40
Hello I have a little question about variable range of variables in $.get() function.
Here I've tried use the glo variable (global) and fill it by data from .lp file. Inside get() function all is perfect but outside glo has still value from before the function.
This is the result from console:
What is the reason of such situation?
Here I've tried use the glo variable (global) and fill it by data from .lp file. Inside get() function all is perfect but outside glo has still value from before the function.
Code:
glo = []
$.get( "/user/hvac_alias.lp", function( data ) { console.log(1, glo); data = data.trim(); data = JSON.parse(data); glo = data; console.log(2, glo)});
console.log(3, glo)
This is the result from console:
Code:
3 Array [ ]
1 Array [ ]
2 Array [ Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, 122 more… ]
What is the reason of such situation?