i am using a variable to store json data coming from post method. and when i am using that variable outside of post method it shows its value as undefined. how do i access that variable. here is my code.
var val;
$.post("dat/jsondat.php",function(data)
{
alert(data);//this alert value
val = data;
alert(val);//this alert value
});
alert(val);//this alert undefined
the val is a global variable. and i need to use this variable in another function after assigned from post method.