JavaScript数组失去作用域且未传递到我的函数
我正在创建一个数组作为TAFFYDB()查询的结果(但任何数组都可以) 我试着在函数调用中传递它JavaScript数组失去作用域且未传递到我的函数,javascript,arrays,scope,Javascript,Arrays,Scope,我正在创建一个数组作为TAFFYDB()查询的结果(但任何数组都可以) 我试着在函数调用中传递它 $("#submissionInput").fadeOut(function(){ $("#anaInputs").load("data/stubs/csaReport.html").promise().done(function(ret){ console.log(ret.length); // shows 1 ?? 我想这是因为我用了承诺或其他巫术。 为什么我失去了视
$("#submissionInput").fadeOut(function(){
$("#anaInputs").load("data/stubs/csaReport.html").promise().done(function(ret){
console.log(ret.length); // shows 1 ??
我想这是因为我用了承诺或其他巫术。
为什么我失去了视野 您确定不需要先将其传递给外部函数吗?像这样:
$("#submissionInput").fadeOut(function(ret){
$("#anaInputs").load("data/stubs/csaReport.html").promise().done(function(ret){
console.log(ret.length); // shows 1 ??
reg
和ret
是不同的变量。什么是reg
?将其替换为ret
对不起,这是一个打字错误。在我的代码中到处都是“ret”在你发布代码后数组是否发生了变异?没有。我必须手动重新键入一些代码以进行澄清,并且有一个打字错误。我已经修复了它。console.log(ret.length);正确显示外部函数调用后的2对不起-您是正确的。你让ret超载了。换句话说,它恰恰相反。删除传入done方法的ret变量。e、 g.$(“#anaInputs”).load(“data/stubs/csaReport.html”).promise().done(function()){
$("#submissionInput").fadeOut(function(ret){
$("#anaInputs").load("data/stubs/csaReport.html").promise().done(function(ret){
console.log(ret.length); // shows 1 ??