将变量传递给Modal

I have rows of fetched data. At each row, I have to call a modal passing its id. In the modal, using that id I have to fetch data and display it in a table.

The question is how can I pass the id (php variable) to the javascript and pass it again to the modal, not to display the id but as a variable?

php/html:

<php $i=0; 
?>
<p>Link 1</p>
<a  data-toggle='modal' href='#form-content' >test</a>
<p>&nbsp;</p>
<php $i=1; 
?>
<p>Link 2</p>
<a  data-toggle='modal' href='#form-content' >test</a>

<div id="form-contact" class="modal hide fade in">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>

    </div>
    <div class="modal-body">
        <form class="contact" name="contact">
            ...
            ...
        </form>
    </div>
    <div class="modal-footer">
        ...
        ...
    </div>
</div>

js:

$(document).ready(function() {
            $("input#submit").click(function() {
                $.ajax({
                    type: "POST",
                    data: $('form.contact').serialize(),
                    beforeSend: function() {
                        $("#form-content").modal('hide');
                        $('#wait').show();
                    },
                    success: function() {
                        $('#wait').hide();
                        document.location.reload();
                    },
                    error: function() {
                        alert("failure");
                    }
                });
                return false;
            });
        });

Thank you.

It might not be the best solution out there but you can do this:

<script type="text/javascript">
  var theBestIdEver = <?php echo $id; ?>
</script>

and after that you use pure javascript to send/receive id to wherever you want. Keep in mind you need to write this piece of script before reading it!