By default ajax calls are asynchronous - that's actually what the 'A' stands for. This means that the your ret function will return before the success function is ever invoked. You have two options for fixing your issue:
- Make your ajax call synchronous - see the async options at http://api.jquery.com/jQuery.ajax/. This is almost always a bad idea, because the entire page will block until the call returns
Invert your control flow so that the desired behavior happens when the success callback is invoked. You can do this by passing a function into ret:
function(as, successHandler) {
...
success: function(msg) {
successHandler(msg == 'true');
}