Fill modal with Bd data in PHP

1

I'm having trouble filling a modal with data coming from an sql query.

I have a list with all products. In this list I have a button that when clicked should open a modal with the details of the product.

Button:

<button type="button" class="btn btn-primary btn-mini" data-toggle="modal" onclick="detalhesProduto(' + retorno[i].id + ')">+ Detalhes</button>

This button passes the product id to the function below:

function detalhesProduto(id) {
    alert(id);
    $('#myModal').modal('show');        
}

In this case, I have another function that connects and scans the database, where I get the product id.

The way it is there, I click on the button and open a dialog with the selected product id, then open the dialog, but I do not know how to fill it with the data ... in this case, if it was filled by

My modal looks like this:

<div class="modal fade bs-detalhes-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h5 class="modal-title" id="myModalLabel">Detalhes</h5>
                </div>
                <div class="modal-body" id="conteudoModal">
                   .............. 
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default btn-mini" data-dismiss="modal">Fechar</button>                        
                </div>
            </div>
        </div>
    </div>

Could you help me with this?

    
asked by anonymous 14.05.2015 / 13:46

1 answer

1

Resolved:

function detalhesProduto(id) {
    $('#myModal').modal('show');
    $("#conteudoModal").load('detalhaProduto.php?id=' + id);
}
    
14.05.2015 / 15:54