async: false Cita: The first letter in Ajax stands for "asynchronous," meaning that the operation occurs in parallel and the order of completion is not guaranteed. The async option to $.ajax() defaults to true, indicating that code execution can continue after the request is made. Setting this option to false (and thus making the call no longer asynchronous) is strongly discouraged, as it can cause the browser to become unresponsive.
Por eso te devuelve undefined (aunque arriba si le habia puesto async false, por eso si me funciono), ve que es lo que mas te conviene, mas que todo por la advertencia que mencionan. Pero en este caso necesitas la respuesta para que el código siga por eso lo puse.