Open div via ajax

Asked

Viewed 146 times

3

Glacier, I need to open one div via ajax 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;

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 All right.

Browser other questions tagged

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