Returning a value from a success callback function
I know this is a simple question with a simple answer, but I can't seem to wrap my brain around it. Sorry for the infantile nature of this post. Anyhow, I am making an AJAX call via JQuery and need the function to return a value from a calling function, like so:
function GetMyValue(varA, varB) {
var ajaxOptions = {
type: 'GET',
dataType: 'json',
url: 'http://my.someurl.com/service', //varA and varB used here but left out for simplicity
success: function (data, textStatus) {
var theReturnValue = data.dataResult;
// I WANT TO RETURN THE VALUE HERE
},
error: function (date, textStatus, errorThrown) {
alert('Error: Go Home');
}
}
$.ajax(ajaxOptions); //The actual AJAX Call
}
function WrapperFunction(valueA, valueB) {
var theReturn = GetMyValue(varA, varB);
alert(theReturn);
}