jayreis 0 Junior Poster in Training

I have a php page that lists a bunch of data including id's from a database. I then have a button next to each id that will open a Twitter Bootstrap modal window in the page and I need to pass the php variable (the id) to that model window so that I can do a mysql query in it.

My issue is the model window is just displaying the textbox I setup that should be showing the unique id. However instead it is showing the textbox with just the word "null" in it.

My code is below The link used to trigger the Modal window. Note I confirmed that the button code does show the value for the php variable id.
My issue is with my jquery/ajax in retrieving the id when the button is clicked

My button code

<a href='#switch_modal' class='btn btn-default btn-small' data-toggle='modal' data-id='<?php echo "$scommentid"; ?>'>REPLY</a>

My jquery/Ajax code

<script>
                    $(document).ready(function() 
                       {
                         $('#switch_modal').on('show.bs.modal', function (e) 
                            {

                              var rowid = $(e.relatedTarget).data('id');                                                                                                 
                              $.ajax({
                                          type : 'post',
                                          url : 'fetch_comment_id.php', //Here you will fetch records 
                                          data :  'rowid='+ rowid, //Pass rowid
                                          success : function(data)
                                         {
                                               $('.fetched-data').html(data);//Show fetched data
                                         }
                                      });
                            });
                       });
             </script>

My fetch_comment_id.php code
$id = $_GET['rowid']; //escape string echo "# <input type='text' name='acommentuid' value='$id'>";

My Twitter bootstrap modal window code
`<div class="modal fade" id="switch_modal" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Reply To Message</h4> </div> <div class="modal-body"> <form method="POST" action=""> <div class="fetched-data"></div> <div class="box_a_content cnt_no_pad"> <textarea name="commentreplymsg" id="wysiwg_editor" cols="30" rows="10">

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.