I would like to have a function that returns the repsonseText of a jQuery.ajax() call. All the examples I've seen say to use a 'success' function to handle the returned data. However, for my implementation I need something like following:
function getRemoteValue(id) {
var request = jQuery.ajax({
url:'somefile.php',
dataType:'text'
});
return request.responseText;
}
When I make a call to this function, Firebug shows the request as going through with the correct Response being returned. However when I try the following, I only get an empty string:
var some_value = getRemoteValue(1); // The problem is here. some_value is empty.
jQuery('.someclass').html(some_value);
// Other processing using some_value;
Again, for my implementation I can't be doing the jQuery('.someclass').html(some_value); within the ajax() call. How can I get the responseText returned? Thank you!