View Full Version : Access/change variable inside lambda function

08-17-2010, 09:28 PM

In one of my functions I got the following lambda function. It works as intended, but I got a tiny problem. I'm trying to access the function-scooped variable "matched" and set it's value to "true". The problem is that it seems like the variable is existing as a local variable inside the lambda function, even if it's not declared inside the lambda function itself. So, the change "matched = true;" does not effect the variable that I declared.

I'm not to familiar with javascript, so it's probably something I have missed. Can anyone lend me a hand?


//... code
var matched = new Boolean(false);

xmlhttp.onreadystatechange=function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(input_name).innerHTML = xmlhttp.responseText;
if(remove_whitespace(xmlhttp.responseText) == "Available") {
matched = true;

08-17-2010, 10:39 PM
Problem solved.