Estou fazendo um sistema que faz uma requisição ajax
com axios. Até aí td bem, consegui fazer a requisição GET
e listar todos os itens na tela, em uma tabela. Nessa tabela tem um botão Ver Item, que devo redirecionar para outra página onde vou mostrar apenas o item em questão. Faço isso com PHP
, mas estou estudando Javascript
e gostaria de saber qual a melhor maneira de fazer isso.
axios.get('http://127.0.0.1:8000/api/post')
.then(function(response){
jQuery.each(response.data, function(key, value){
//REQUISIÇÃO AJAX COM AXIOS
jQuery.each(value, function(label, answer){
display = '\
<tr>\
<td>' + value.id + '</td>\
<td>' + value.title + '</td>\
<td>\
<button id="btn'+ value.id +'" class="btn btn-primary">Ver detalhes</button>\
</td>\
</tr>'
});
$('#tbody').append(display);
//BOTÃO QUE DEVE REDIRECIONAR PARA OUTRA PÁGINA
$('#btn' + value.id ).click(function() {
window.location.href = "post.html";
});
});
});
window.location.href
, qual é exatamente a sua dúvida?<a>
) com o atributohref
? :)