So I've been fighting this issue for a few days now and I still can't figure out why this global variable doesn't seem to retain the changed value between function calls..
I've also tried adding window.Client_Model = {} and then calling window.Client_Model with the same results.
var Client_Model = {};
// after page loads
$(document).ready(function() {
get_server_model();
$("#demohi").text(JSON.stringify(Client_Model)); //outputs blank dictionary
//get_page_elements();
//send_graph_data();
});
function get_server_model(){
$.post( "/get_server_model", {
"cmd": "GET_SERVER_MODEL"
}, function(resp){
var response = JSON.parse(resp);
if (response.error === true)
{
alert("Error");
}
else
{
Client_Model = response.server_model;
set_page_elements(response.server_model);
$("#demolow").text(JSON.stringify(Client_Model.graph_lines)); // correct output
}
});
}