0

I assigned several bootstrap tooltips to some span elements.

I use this javascript / jquery code:

function tooltip()
{
 $('.tooltipelement').tooltip({
 trigger: 'click',
 title:loadtranslation
 });
}

function loadtranslation()
{
 var id = $(this).attr("data-id");
 $.post("ajax.php",{"mode" : "w1", "id" : id},function(data){
    return "x";
 });            
}

It doesn't work: The tooltip is not shown. If I skip the ajax request like this:

function loadtranslation()
{
    return "x";        
}

The tooltip is shown and "x" is displayed. It is not a failure on the ajax request, because I even don't evaluate the result but just return "x" as well. I guess there is a kind of time-out issue (ajax request takes several milliseconds - mayto too long for the tooltip function?)

simonheinrich
  • 91
  • 1
  • 8
  • Gah, closed with the wrong thread and now I can't close it again. This is a dupe of https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call if any other mod comes in here – Taplar Nov 01 '19 at 15:26
  • Thanks for this link. You are right. – simonheinrich Nov 01 '19 at 15:47
  • Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – brooksrelyt Nov 01 '19 at 15:56

0 Answers0