I have a javascript function foo. I want bar to be called when foo is complete. I have tried it as a callback. It does not work. Bar is called while foo is still executing the $.get (which starts a very long python routine on the server).
function foo(callback){
$.get(
url="/myurl",
data={key:($(this).attr('data-button'))},
function(returndata) {
var array = eval(returndata);
drawTable(array);
});
callback();
}
foo(bar);
This however works. I am confused as to why...
function foo(callback){
$.get(
url="/myurl",
data={key:($(this).attr('data-button'))},
function(returndata) {
var array = eval(returndata);
drawTable(array);
callback();
});
}
foo(bar);