I have event_id php variable in current page. and I want to display it in jquery tooltip using ajax(must). But there's error that event_id isn't defined
jquery file which has tooltip function:
function tooltip(self){
$(document).ready(function(){
$("tr").tooltip({
track: true,
content: function(){
$.ajax({
url: window.location.pathname,//current url
type: 'post',
data: {event_id}, //undefined
success: function(data){
$('#tooltip_td').attr('title', data);
}
});
}
});
$("tr").mouseout(function(){
$(this).attr('title','Please wait...');
$(this).tooltip();
$('.ui-tooltip').hide();
});
});
}
index.blade.php: // I call tooltip function in this html file. // $participant has event_id
<tr>
<td class="can_filter">{{ $participant['id'] }}</td>
<td class="can_filter" id="tooltip_td" data-js="{{ $participant['event_id'] }}" title="Any default tooltip title" onclick="
tooltip(this);
">{{ $participant['name'] }}</td>
what should I have to do? Thank in advance!
event_idanywhere in your JS, or given it a value...?event_idin index.blade.php to jquery file : ) and display it in tooltipcontent: function(){ $event_id = $('#tooltip_td').attr('data-js'); $.ajax({ url: window.location.pathname, type: 'post', data: {event_id}, ...?