var heroes = {"1":"shit 1" };
function myReturn(val){
return val;
}
$(document).tooltip({
items:'.hero',
tooltipClass:'preview-tip',
position: { my: "left+15 top", at: "right center" },
content:function(myReturn) {
var elt = $( this );
var hero_id = elt.data("id");
if (typeof(heroes[hero_id]) != "undefined"){
return heroes[hero_id];
}
else{
var answer;
$.ajax({
url: "ajax_1.php",
method: "POST",
data: "a=1&b=2"
}).done(function(data) {
heroes[hero_id] = data;
myReturn(data);
}).fail(function() {
return "error";
});
}
}
});