Answer the question
In order to leave comments, you need to log in
How to take an array out of a function in JS?
Good day to all, please tell me how to take out an array with cities for a function so that you can access it globally? I'm a newbie myself :)
function initInputHint() {
$.get('?cities=cities', {}, function (cities) {
var arr = new Array();
var i = 0;
$.each(cities, function (index, obj) {
if ('ru' in obj.name_translations) {
arr[i++] = obj.name_translations.ru;
}
});
$('#form-avia input.hint').autocomplete({source : arr});
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question