trying to get the getFromWho function to return the recipient text from xml file, I can get it to log the text, but for some reason I cannot get it to return in the function.
function preSubmit(){
var optionTexts = [];
$("section").each(function(){
var h2 = $(this).find("h2").text();
optionTexts.push(h2);
optionTexts.push("\n");
$("ol li", this).each(function() { optionTexts.push($(this).text()) })
});
var splitText = optionTexts.join("\n");
console.log(splitText)
splitText += getFromWho();
return splitText;
}
function getFromWho() {
$.ajax({
type: "GET",
url: "forWho.xml",
dataType: "xml",
success: function(xml) {
console.log($(xml).find('recipient').text())
return $(xml).find('recipient').text();
}
});
}