function lookupRemote(searchTerm)
{
var defaultReturnValue = 1010;
var returnValue = defaultReturnValue;
$.getJSON(remote, function(data)
{
if (data != null)
{
$.each(data.items, function(i, item)
{
returnValue = item.libraryOfCongressNumber;
});
}
});
return returnValue;
}
Run Code Online (Sandbox Code Playgroud)
为什么returnValuefrom this函数总是等于在函数开头设置的默认值,而从不等于从JSON查找中检索的值?