Hi I have a global variable "usuario" and I want to put it a value that I get from the $.post function, but doesnt work. The variable holds its original value. I did a test, I put an alert(usuario); into the function and it works, the alert shows the value from the function. The code below:
<script type="text/javascript" >
var usuario="";
$.post("cargarDatos.php",{},function(r){
usuario = r;
alert(usuario);
});
if(usuario !== "Nada"){
document.write("El usuario conectado es: "+usuario);
document.title="Actividad de "+usuario;
}else{
document.write("No hay usuario conectado!");
}
</script>
ifandelseinside your success function