61
rated 0 times
[
68]
[
7]
/ answers: 1 / hits: 34387
/ 14 Years ago, mon, october 18, 2010, 12:00:00
I would like to put an ajax call within a function since I use it repeatedly in multiple locations. I want a manipulated version of the response returned. Here's what I'm trying to do (greatly simplified).
a = getAjax();
$('body').append('<div>'+a+'</div>');
function getAjax() {
$.ajax({
type: GET,
url: 'someURL',
success: function(response) {
return response;
});
}
What's happening, however, is that the append function is running before a has been defined in the getAjax function. Any thoughts?
More From » jquery