[eluser]Victor Michnowicz[/eluser]
The problem is that you are using AJAX. This means that your $.post is asynchronous. So your "return result;" is being run way before you AJAX request has even finished. You can make your $.post synchronous like so:
Code:
$.ajaxSetup({async:false});
However, I would guess that there is probably a better way to accomplish what you are trying to do.