Passing variable to an inner function
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开发者_如何学C this doQueryResults(t,ssn) but it doesn't work.Any help appreciated.
Thanks
ECMA-/Javascript has a static (lexical) scope. It also has the feature, that an "innerContext" closes over an "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.
So if alert(ssn);
is undefined, it is also undefined when calling getSsrBandAid()
.
精彩评论