0
I’m making a system that makes a requisition ajax
with Xios. So far td well, I was able to make the request GET
and list all items on the screen in a table. In this table there is a button View Item, that I should redirect to another page where I will show only the item in question. I do this with PHP
, but I’m studying Javascript
and would like to know what is the best way to do that.
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";
});
});
});
that’s right...
window.location.href
, what exactly is your doubt?– Leandro Angelo
Why instead of creating a button you don’t create a link (
<a>
) with the attributehref
? :)– Luiz Felipe
my question is how to pass the parameters to the other page, I need to get a get with the item id or I can send the parameters directly from that page and just read it on the other page. If yes, how to do this??
– Edinho Rodrigues