I have been trying to do this
function test()
{
$.getJSON("http://myurl.com",function (data){
for( i=0; i<data.length; i++){
test = createElement('img');
test.onclick = function (){ myotherfun(data[i]); }
}
}
}
function myotherfun(data)
{
alert(data);
}
An error message states that data
isn't covered by the scope.
Can some one explain why this happens?