使用回调,我有以下代码
var TK = {
List: [],
getSectionA: function(listName, callback)
{
var arrayList = [];
$.get('ajax/test.html', {sendName: listName}, function(data) {
$.each(data, function()
{
arrayList = data;
});
callback(arrayList);
});
}
};
调用函数
$("#dropDownList").change(function()
{
TK.getSectionA(fileName, function(data)
{
TK.List = data;
alert(TK.List); // This works ok...
});
alert(TK.List); // This does not work when calling using this property outside the callback..
});
我怎样才能让它在另一个函数中的回调函数之外工作