Here's my jQuery function,
$.post("assets/scripts/chat/get_user_info.php", {UserID: UserID}, function(data){
if (data == "error") {
alertBar('negative','There was an error sending the message');
}
var username = data;
})
But I only use the "data" or "username" variable in the function itself, so how can I use it globally around the whole page?
window.username = data;. However, not declaring a variable usingvaris a bad practice, and will throw errors in strict mode.