I have an AJAX request that gets data from a page and should insert it into a bootstrap popover, but it does not work.
$(document).ready(function(){
$('#req').popover({
html : true,
content: function() {
$.ajax({
url: "/requests",
success: function(data){
var page = $(data);
var req = page.find('#reqP').html();
console.log(req);
return $(req).html();
}
});
}
});
});
This gets the data fine and logs to the console, but it does not show up in the popover. I'm new to JS, so I'm probably missing something obvious.
Also, in your answer if you could include why what I'm doing is not working, that would be great.
EDIT: I also tried to add return
before the $.ajax(...)
request, which didn't work.