how to populate modal popup using jquery code example

Example: populate modal from table

<script>
$(function(){
    $('#infoModal').modal({
        keyboard: true,
        backdrop: "static",
        show:false,

    }).on('show.bs.modal', function(){
          var getIdFromRow = $(event.target).closest('tr').data('id');
          var name = $(event.target).closest('tr').find('td:eq( 0 )').html();
          var pos = $(event.target).closest('tr').find('td:eq( 1 )').html();
        //make your ajax call populate items or what even you need
        $(this).find('#orderDetails').html($('<b> Order Id selected: ' + getIdFromRow  + '</b>'));
        $(this).find('#name').text(name);
        $(this).find('#pos').text(pos);
    });

});
</script>