[jQuery] Var from Ajax success not defined?

[jQuery] Var from Ajax success not defined?


Hi,
$.ajax({
        type: "POST",
        url: "/ajax_add_selected_product_to_session.php",
        success: function(msg){
            /* add here what to do on success */
            //alert(msg);
            var how_many_checked = msg;
        }
    });
alert(how_many_checked);
if(how_many_checked > 0) .......
the FF returns "how_many_checked" ist not defined.
Why?
How can I define a var and use it for a later coming if / else part?
Thanks a bunch!