var myvar = "my value";
(function() {
alert(myvar); // undefined
})();
or
var myvar = "my value";
$.post( url,
function( data ) {
alert(myvar); // undefined
});
and how can I solve this issue without storing this value in a hidden input or div or other html containers ??