无法从外部访问$ .get()内部声明的全局变量

时间:2016-02-24 17:33:19

标签: javascript jquery global-variables

所以,这是代码

$(document).ready(function (){

    $.get("json_family.php", {}, function(data) {
        families = data;
    }, 'json');

    console.log(families);

// Some other codes here
});

以下是我尝试运行时会发生的事情:

Uncaught ReferenceError: families is not defined

那么,是什么给出的?我认为没有var关键字声明的变量无论在何处被声明都是全局的。

0 个答案:

没有答案
相关问题