I am currently working on an ajax request that retrieves information such as username, email, and user_id. Once the ajax call is successful, I use jQuery to append this data to the title tag. The main issue I am facing is that the data is only displayed after hovering for the second time, not on the first attempt.
Below is the code snippet:
function showProfile(i)
{
var user = $("#user_id_"+i).html();
var business = <?php echo $this->identity()->getBusiness()->getId() ?>;
$.ajax({
'url': '/user/account/external/profile',
'type':'GET',
'data':{
businessId:business,
userId:user,
},
'success': function (data) {
var message = "Fullname : "+data.first_name+" "+data.last_name+" Email : "+data.email;
$("#user_id_"+i).attr('title',data.first_name+'\n'+data.last_name+'\n' +data.email);
},
});
}
Here is the HTML code initiating the ajax call:
<a id="user_id_btn_'.$k.'" class="user_id_btn" onmouseover="showProfile('.$k.')" onmouseout="hideProfile('.$k.')"><span id="user_id_'.$k.'">'.$iResult[$k][4].'</span></a>
Is there a way to improve this setup so that the data shows on hover during the first attempt?