Passing method GET by Jquery

0

I have the following situation, when testo is passing the parameter with var_dump , it does not return.

What I'm trying to do is not load a new page but everything happens on the divs.

HTML:

<td align="center"> 
    <?php echo '<a id="consulta" href="ver_imagem.phpid='.$aquivos['id_img'].'">Imagem '.$aquivos['id_img'].' </a>'; ?>
</td>

In script I try this:

<script type="text/javascript">
    jQuery(document).ready(function(){

        jQuery('#consulta').click(function(){
            var dados = jQuery( this ).serialize();

            jQuery.ajax({
                type: "GET",
                url: "ver_imagem.php",
                data: dados,
                success: function( data )
                {
                $("#imagens_pn").empty();
                $("#imagens_pn").append(data);

                }
            });

            return false;
        });
    });             
</script>
    
asked by anonymous 02.05.2017 / 20:54

2 answers

0

<?php echo '<a id="consulta" href="id='.$aquivos['id_img'].'">Imagem '.$aquivos['id_img'].' </a>'; ?>


<script type="text/javascript">
    $(document).ready(function(){

        jQuery('#consulta').click(function(){

          var me = $(this);
          var dados = me.attr("href");

            jQuery.ajax({
                type: "GET",
                url: "ver_imagem.php",
                data: dados,
                success: function( data )
                {
                $("#imagens_pn").empty();
                $("#imagens_pn").append(data);

                }
            });

            return false;
        });
    });             
</script>
    
03.05.2017 / 04:32
0
 jQuery.ajax({
            type: "GET",
            url: "ver_imagem.php",
            data: {
                nomeVariavelServer: $("#consulta").attr("href")
            },
            success: function (data) {
                $("#imagens_pn").empty();
                $("#imagens_pn").append(data);

            }
        });

The name of the variable must be the same as the parameter expected in api. API:

metodo(nomeVariavelServer)
{

}
    
04.05.2017 / 16:51