Problem with GET Request

Asked

Viewed 64 times

0

I am successfully using the script below to open in Visual DIV, products related to selected brand:

Link to the Brands:

<a class="marca" style="cursor:pointer;" id="'.$res['codigo'].'">'.$res['nome_marca'].'</a>

Script for the Tags:

<script language="javascript">
////// Visualiza o produto da Marca selecionada //////
$(document).ready(function(){
    $('.marca').click(function(){
        var cod = $(this).attr('id');
        $.ajax({url:"prod_index_marca.php?codmarca="+cod,success:function(data){
            $('#visual').html(data);
            }
        });
    });
});
</script>

In sequence, I would like to open the details of each Brand product selected from within the Visual DIV, for itself.

I used the same method to open the brands, so:

Link to Product Details:

<a class="detalhe_5" style="cursor:pointer;" id="<?php echo $res['codigo']; ?>">
    <img style="width:100%; max-width:100px;" src="img_produtos/<?php echo $res['img01']; ?>" />
</a>

Script for the Details:

<script language="javascript">
////// Para visualizar o item selecionado //////
$(document).ready(function(){
    $(".detalhe_5").click(function(){
        var cod = $(this).attr("id");
        $.ajax({
            url:"prod_detalhe_5.php?codigo="+cod,success:function(data){
            $("#visual").html(data);
            }
        });
    });
});
</script>

But I’m not getting an answer, when I click on the link, the page becomes static, ie nothing happens.

I can count on friends to solve this problem?

I can’t figure out why it doesn’t work.

  • On console shows some error?

  • if you access the url directly in the browser get some response?

  • Hello Lucas Brogni, yes I downloaded the URL and returned the following message: "Undefined index: codigo in C: wamp www Commerce prod_5.php on line 11" .

  • And on the "prod_details_5.php" page it looks like this:

  • <?php&#xA; $codigo = $_GET['codigo'];&#xA; $sql = $pdo->prepare("SELECT * FROM produto WHERE codigo = $codigo") or die(mysql_error());&#xA; $sql->execute();&#xA; foreach($sql->fetchAll() as $res){&#xA; ?>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.