I got a question, probably very simple, but whatever. When registering an event listener inside an asynchronous function, I would believe that all values within that function would be non-existing when the function has run it's course.
However, an event listener, as displayed below in the code can still access the variable values
, how is that? Is the variable saved within the event listener somehow?
$.ajax({
type: "GET",
cache: false,
url: "/whatever",
success: function(data) {
var values = ["Some Values", "Inside this Object"];
$("#id :checkbox").click(function() {
var allValues = [];
$('#id3 :checked').each(function() {
allValues.push($(this).val());
});
$("#id2").val(allValues);
callMe.init(values,allValues);
});
}
});