I\'m sure you know this problem, I\'m still trying to solve it for few days. I\'ve tried lots of stuff but no one worked:
Here is the code
function l
When you return values from within an anonymous function that is executed asynchronously, those values will not propogate up the scope chain, the return statement is only applied on the current function scope, not the surrounding scope, $.ajax() is asynchronous, so immediately after executing the statement, the outer function returns, so there is no return value of the outer function, that's why you're getting undefined.
The only way to hook into a possible return value from the callback function passed to $.ajax is to invoke another outer function, passing in the desired data.