Hello, everyone.
I'm trying to popular a list-group bootstrap with ajax but I'm not getting it. I have already researched several places about it and could not resolve it.
The php code is ok and the json that returns from php is also ok.
Follow the html code
<!DOCTYPE html>
<html>
<header>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<script type="text/javascript">
$(document).ready(function(){
$('#lista').empty();
$.ajax({
type:'GET',
url: 'artigos.php',
dataType: 'json',
success: function(dados){
for(var i=0;dados.length>i;i++){
$('#lista').append('<a href=\"artigos/'+dados[i].link+'?id='+dados[i].id'\" class=\"list-group-item\">'+dados[i].titulo+'</a>');
}
}
});
});
</script>
</header>
<body>
<div class="page-header text-center">
<h1>Artigos <br /><small>Selecione um item para ler o artigo</small></h1>
</div>
<div class="list-group" id="lista">
</div>
<script src="js/jquery-3.2.1.min.js"></script>
</body>
</html>