I'm trying learn to pass a value from a php to modal but it does not seems to work, there are no errors in console.
this is my php inside a while loop
echo'
<tbody>
<tr>
<td>'.$row->equipID.'</td>
<td>'.$row->equipType.'</td>
<td>
<a href="#editModal" class="btn btn-info btn-xs" data-id="'.$row->equipID.'" data-toggle="modal">
<i class="fa fa-pencil"></i> Edit </a>
</td>
</tr>
</tbody>';
this is the html file where i want to pass the value from the php
<div class="modal fade" id="editModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<h3 class="modal-title">Edit Truck Category</h3>
<div class="modal-body">
<form>
<div class = "fetched-data"></div>
<input type="text" id="truck" placeholder="Truck Category *" required>
</form>
</div>
</div>
</div>
</div>
this is my js
<script>
$(document).ready(function(){
$('#editModal').on('show.bs.modal', function (e) {
var rowid = $(e.relatedTarget).data('id');
$.ajax({
type : 'post',
url : 'fetch_record.php', //Here you will fetch records
data : 'rowid='+ rowid, //Pass $id
success : function(data){
$('.fetched-data').html(data);//Show fetched data from database
}
});
});
});
</script>
Thank you very much in advance.