I have function bar which I need to call. I'm new to using callbacks, from what I understand the callback is still inside the scope of the ajax so it can't see bar. Is it possible to call bar on ajax success? bar is defined in module top.
define(["top"], function() {
function foo(callback) {
$.ajax({
type: "GET",
cache: false,
dataType: 'json',
url: "http://asdf/qwer",
success: function(response) {
callback(response);
}
});
}
foo(function(response) {
bar(response);
});
});
bardefined in thetopmodule. Is it an object with a property.bar?