javascript - Overriding variable value inside the $.get() -


this question has answer here:

i facing quite strange problem, dont seem able override variable jsondata inside success function of $.get()

$.fn.name = function(data, options) {         var jsondata = data;         var settings = $.extend({                 ....                 }, options);          if(typeof data !== 'object') {             if(settings.debug) console.log('getting configuration settings from: ', data);             $.get(data, function(d) {                 jsondata = d; //i attempt override value here             }, 'json');         }         console.log(jsondata); // gives same value before }; 

note: success event of $.get() triggered

by time logged value, $.get() has not overridden jsondata yet since ajax request has not returned time. console.log inside function instead.

$.get(data, function(d) {   jsondata = d; //i attempt override value here - did!   console.log(jsondata); }, 'json'); 

Comments

Popular posts from this blog

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -