There are two parts to your question that need to be resolved - the first relates to the asynchronous nature of AJAX and how results are returned - for that see the canonical answer to the question that this was originally marked as a duplicate of.
The second part is how to make the final answer depend on the asynchronous completion of all ten AJAX requests:
function functionOne() {
// initiate ten requests, storing the promises in an array
var def = [];
for (var i = 0; i < 10; ++i) {
def[i] = AjaxFunction();
}
// wait for all the promises to complete, with the
// eventual result also being returned as a promise
return $.when.apply($, def).then(function() {
// take a copy of the arguments
var args = [].slice.call(arguments, 0);
// concatenate them all together
return args.reduce(function(prev, current) {
return prev + current[0]; // each arg is actually a 3-element array
}, "");
});
}
function AjaxFunction() {
return $.get('/test'); // NB: using promises - no callback required
};
// NB: functionOne() is now also async - you have to wait
// for the promise to be resolved before using the result
functionOne().then(function(result) {
alert(result);
)};
See http://jsfiddle.net/alnitak/5s28G/ for a working demo.