1
I have Ajax that loads database data and json type:
$.ajax({
type:'post',
dataType: 'json',
url: '../model/dao/CursoDao.php?acao=1',
success: function(dados){
for(var i=0; dados.length > i; i++){
$('#listaCursos').append('<a href="sala_view.php?idcurso='+ dados[i].id + '" class="btn btn-primary texto-grande botao-nivel sombra">' + dados[i].titulo +'</a>');
}
}
});
The function of PHP:
public function listaCursoAjax() {
$sqlCurso = $this->conexao->prepare('SELECT * FROM curso');
$sqlCurso->execute();
while($linha = $sqlCurso->fetch(PDO::FETCH_ASSOC)) {
$vetor[] = array_map('utf8_encode',$linha);
}
echo json_encode($vetor);
}
Try to encode to Base64 and decode on the output, the accents should remain as they were :)
– Wesley Nascimento
@Wesleybirth when so array_map('base64_encode',$line) get even worse
– Rodrigo Jacinto
I’ll answer you right, you’re doing it wrong.
– Wesley Nascimento
See what I edited and give me a feedback, whether it worked or not...
– Wesley Nascimento
With chair will it work?
– Sam