Maybe you are unfamiliar with asynchronous operations. In your code, your if-else check at the bottom of your code is actually executing before your success callback. 
What you are probably observing is that dch is always 0. You instead need to continue the execution of your code inside the callback:
var aid='11111111V';
var dch = 0;
$.ajax({
    type:"POST",
    url:"new_hpa_fun_aplcval.php",
    data:"aid="+aid,
    success: function(msg) {            
        if (msg =='OK'){
            // perform something here                    
        } else {
            // perform something here
        }
    }
});
In this case, you don't even need the dch variable.
Your other option is to make the AJAX call synchronous by adding async: false to the options in the $.ajax method. This will cause your code to block and wait for the response before it continues executing.
See the Wiki on Ajax for a more technical description of what's happening under the hood of jQuery.