I have this script:
function getUsername() {
$.ajax("http://one2xs.com/index.php", {
success: function(a) {
console.log($(a).find("#left").html().match(/Je bent ingelogd als ([ ^A-z0-9]*)/)[1]);
return $(a).find("#left").html().match(/Je bent ingelogd als ([ ^A-z0-9]*)/)[1];
}
});
}
alert(getUsername());
In the console log it says my username:
But the alert is 'undefined', I dont know why. I have already doing some debugging but its will not work. Does somebody know why my username works in the console log but not in the alert?
Thanks.