Load a Bootstrap popover content with AJAX
Loading a content via AJAX in a Bootstrap popover is a very common pattern and, although it is not supported out of the box by Bootstrap, it is very easy to get this functionality with jQuery.
First we should add a data-poload
attribute to the elements you would like to add a pop over to. The content of this attribute should be the url to be loaded (absolute or relative):
<a href="#" title="blabla" data-poload="/test.php">blabla</a>
And in JavaScript, preferably in a $(document).ready();
off('hover')
prevents loading data more than once and popover()
binds a new hover event. If you want the data to be refreshed at every hover event, you should remove the off
.
Please see the working JSFiddle of the example.
This blog post is created using my original answer on stackoverflow.