Open div via ajax

3

Gelera, I need to open a div via ajax by passing a ID via POST . Where am I going wrong.

HTML

<div class="row">
   <div id="retorno_galeria">
    <a onclick="galeria_id(this.id,' . $gal["id"] . ');" href="#">
   </div>
</div>

JavaScript

function galeria_id(id) {
    var idGaleria = (this.value.id);
    $.post(URL + 'Ajax/galeria', {val: idGaleria}, function (busca) {
        $('#retorno_galeria').html(busca);
    });
}

PHP

case 'galeria':

    $char = $_POST['val'];

    $tbody .= 'Teste retorno galeria ' . $char . '';

    $retorno = $tbody;

break;
    
asked by anonymous 18.01.2017 / 17:10

1 answer

2

HTML

<div class="row">
   <div id="retorno_galeria">
    <a onclick="galeria_id(this.id)" id="<?=$gal["id"]; ?>" href="#">
      LINK
    </a>
   </div>
</div>

JS

function galeria_id(id) {
    $.post(URL + 'Ajax/galeria', {val: id}, function (busca) {
        $('#retorno_galeria').html(busca);
    });
}

PHP Okay.

    
18.01.2017 / 17:23