Retrieve parameter sent to a modal and perform MySQL query

1

I need to retrieve parameter sent to a modal bootstrap, perform a query in the database and show result in a text field for the user, what I have is this:

Sending the parameter to the modal

<i class="icon-large  icon-book" onclick="VerComentario()" IdCandidato=<?php echo $IdCandidato; ?>></i>

The modal call

     // Chamada da janela modal para ver o Comentário
function VerComentario() {
    $("#VerComentario").modal({
        backdrop: false
    });
    $("#VerComentario .modal-header h3").html("Observação Cadastrada");
    $("#VerComentario").modal("show");
}

In the modal I have this SQL

    <?php

    $IdCandidato = $_GET['IdCandidato'];

    require_once('../Connections/conCurriculoCocari.php');
        $query = "SELECT * FROM observacao  WHERE id_candidato = $IdCandidato ";
        $result = mysql_query($query) or die ('Error (' . mysql_errno() . ') ' . mysql_error());
    ?> 

But the parameter is not being sent, I need to receive the same, send to the modal to make the select and show the result to the user

    
asked by anonymous 09.06.2014 / 23:58

1 answer

1

Whenever you want to save some information in an attribute of <tag> that is not valid HTML you have to use the prefix data- .

Consider the following HTML:

<div id="minha-div" data-mensagem="Olá Mundo!"></div>

You can retrieve information as follows (using jQuery):

alert( $("#minha-div").data("mensagem") );

See in JSFiddle: link

    
10.06.2014 / 15:49