I'm trying to return a value from inside jQuery.post inside a function, so far the value returned is undefined.
How do i solve?
function check_file(title) {
                    var url = "http://www.example.com/wp-content/check_download.php";
                    var data = {
                        title:title
                    };
                    jQuery.post(url,data,function(response) {
                        if(response==1) {
                            //if file exists
                            return 1;
                        } else {
                            //file doesn't exist keep checking until it does
                            setTimeout(function () {
                                check_file(title);
                            }, 1000);
                        }
                    });         
                }
It should return 1 from the function check_file but it returns undefined how do i solve?
