I'm trying to pass a variable to a function as fined in several documentations, and even here on StackOverflow, but when I define it... it doesn't work... if I set the variable to true prior to the function it works fine. And it is getting to the part where it should be defining proceed as true as it's alerting me... but it doesn't change the var
I realize this timeout does nothing to delay the execution of each loop, never mind that. :P Haven't removed it.
var rand = function() {
return Math.random().toString(36).substr(2);
};
$(function(){
$('.lhc').each(function() {
var rawlink = $(this).attr("href");
var link = encodeURIComponent( rawlink );
var token = rand();
var proceed;
$.get( "lhc/link.php?link=" + link + "&a=c", function( data ) {
if ( data == 1 ) {
proceed = true;
alert('true');
} else {
proceed = false;
}
});
if ( proceed ) {
$(this).after( " <span style='font-size:xx-small;'>( Hits: <span id='" + token + "'></span> )</span>" );
setTimeout($.get( "lhc/link.php?link=" + link + "&a=q", function( data ) {
$('#' + token).html(data);
}), 3000);
$(this).attr( "href", "lhc/link.php?link=" + link + "&a=g" );
}
});
});