I am attempting to use the return value from a nested ajax function as the value for a variable in its parent. However, despite being able to successfully assign the variable within the nested function, it reverts back to its original value after the child function has terminated. Below is the code:
$('a[href^=logmar]').tooltip({ bodyHandler: function() { var args = $(this).attr("href").split('?')[1]; var lm_out = "test"; // <-- attempting to set lm_out if(args.charAt(0) == "l") { var lm = args.substring(2, args.length); $.get("templates/templates.php", {'action': 'lm2sn', 'l' : lm }, function(response){ if(response.length > 0) { lm_out = response; alert(lm_out); // <-- no problem here } }); } return lm_out; // <-- value has returned to "test" }, showURL: false }); Any suggestions on how to tackle would be most welcome. I have read so much about scope and closure tonight that my eyes are bleary! Thanks, Rick