global variable is showing blank always in jquery -


i have created global variable in jquery. created function in making jquery call , setting response var global variable. when doing console.log global var, showing blank always. code did is

var currentname = ""; function getcurrentname() {     $.get(         url     ).success(function(response) {         response = json.parse(response);         currentname = response.name;     }); } getcurrentname(); console.log(currentname); 

so should use variable globally.

you should use async : false in ajax request


Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

html - How to custom Bootstrap grid height? -