-4
Hello I have a Od in js that takes id of a field and with this id(value) I need to use in if Else within php to display posts related that id as the user click down the Cod that picks up the id
<script>
jQuery(document).ready(function($){
$(".linha-produtos").click(function(){
var categorias = $(this).attr("id");
//console.log(categorias);
$("#recebe-indice").attr('src',categorias);
});
//aqui
$(".nav-item").click(function(){
var capacitancia = $(this).attr("id");
});
});
</script>
My PHP code
<?php
$nome = $_POST['capacitanciaa'];
if ( $categories1->have_posts() ) : while ( $categories1->have_posts() ) : $categories1->the_post();
$linha = get_the_title() ;
$slug = get_post_field( 'post_name', get_post() ); ;
if($category->name == "440V")
echo'<p id ="capacitancias" class="tabela-linhax"> '.$linha.' </p>'; else{
};?>
<?php
endwhile;
endif;
?>
Your question is very confusing. But with the information on it, you can’t do what you want, AJAX is designed to make asynchronous requests. To do this you want if I understand correctly, you will use the AJAX request for a file
.php
return ajson
for you in HTML through AJAX/Javascript be able to show on screen according to the "Id" of the button you click.– William
Oie , after mounting the ajax var capacitancia = jQuery(this). attr("id"); //console.log(capacitance); var page ="https://williarts.ga/tslcompos/products/" var data = capacitance; $. ajax({ type: 'POST', dataType: 'html', url:data, });
– fabio
Your question seems to have some problems and your experience here in Stack Overflow may not be the best because of it. We want you to do well here and get what you want, but for that we need you to do your part. Here are some guidelines that will help you: Stack Overflow Survival Guide in English (short version). If the solution is very simple it is still possible for someone to do so in the comments.
– Augusto Vasques