将变量传递给内部函数

时间:2021-08-11 23:20:16
function getSsrBandAid(ssn,id) {    
   DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'getSsrBandAid', ssn, doQueryResults); //calling method in decRequest.cfc    
   function doQueryResults(t){  
     xmlT = loadXMLString(t);  
     alert(ssn);            
   }
}

Trying to pass ssn to doQueryResults() function.
I have tried to this doQueryResults(t,ssn) but it doesn't work.

试图将ssn传递给doQueryResults()函数。我试过这个doQueryResults(t,ssn),但它不起作用。

Any help appreciated.

任何帮助赞赏。

Thanks

谢谢

1 个解决方案

#1


1  

ECMA-/Javascript has a static (lexical) scope. It also has the feature, that an "innerContext" closes over an "outerContext".

ECMA- / Javascript具有静态(词法)范围。它还具有“innerContext”关闭“outerContext”的功能。

To make a long long story short, your doQueryResults() will copy the parent Scope (which is getSsrBandAid). That includes the Activation object which holds the arguments.

长话短说,doQueryResults()将复制父Scope(即getSsrBandAid)。这包括保存参数的Activation对象。

So if alert(ssn); is undefined, it is also undefined when calling getSsrBandAid().

所以如果警报(ssn);未定义,调用getSsrBandAid()时也未定义。

#1


1  

ECMA-/Javascript has a static (lexical) scope. It also has the feature, that an "innerContext" closes over an "outerContext".

ECMA- / Javascript具有静态(词法)范围。它还具有“innerContext”关闭“outerContext”的功能。

To make a long long story short, your doQueryResults() will copy the parent Scope (which is getSsrBandAid). That includes the Activation object which holds the arguments.

长话短说,doQueryResults()将复制父Scope(即getSsrBandAid)。这包括保存参数的Activation对象。

So if alert(ssn); is undefined, it is also undefined when calling getSsrBandAid().

所以如果警报(ssn);未定义,调用getSsrBandAid()时也未定义。