I'm developing a custom jQuery tooltip function with some parameters, such as 'content', which can be predefined. Now I want to add the possibility to fetch some html / json with an ajax callback and pass this to the 'content'-parameter, but I can't get it to work.
My function looks like this:
$("div.tooltip").each(function(){
$(this).myTooltip({
'content':$.ajax({
url: '/request.php',
type: 'GET',
data: {
action:'getcontent',
date:$(this).attr('rel')
},
dataType: 'json',
success: function(result) {
return result;
}
}),
'someotherargs': .....
});
});
The content within the tooltip will be '[object XMLHttpRequest]' so I assume the callback object is returned, not the response..
What am I doing wrong (besides that there may be some typo in the ajax callback)? Thanks in advance