我正在用 php 開發一個頁面,該頁面具有多個動態模式,用于在頁面本身中顯示具有各自標題和作者姓名的 pdf 文件。所有的數據都來自一個用 MySQL 設計的數據庫。觸發按鈕也應該是動態的。我已經嘗試了以下代碼。問題是我讓模態框空白。我能夠在fetch-reader.php頁面本身中打印數據。我認為我在AJAX或模態部分做錯了什么。請指導我完成它。<?php $sqlGal = "select * from articles where year = '2019'";$queryGal = $con->query($sqlGal);if ($queryGal->num_rows > 0) { while ($row = $queryGal->fetch_array()) { ?> <div class="col-md-3 gallery-grid"> <h3 style="height: 200px; vertical-align: bottom; margin: 0; display: table-cell;"><?php echo($row['title']) ?></h3> by<h4><?php echo($row['name']) ?></h4> <a href="#myReader" class="btn btn-success" id="readerID" data-toggle="modal" data-id="<?php echo($row['id']); ?>"> <i class="fa fas fa-book-open"></i> Read</a> </div> <?php }}?><div class="clearfix"></div><div class="modal fade" id="myReader" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header header"> <button type="button" class="close" data-dismiss="modal">×</button> <h3 id="articleName"></h3> <h4 id="name"></h4> <h6 id="position"></h6> <h6 id="address"></h6> </div> <div class="modal-body"> <object data="" id="reader" width="100%" height="450px"></object></div> </div> </div> </div></div>請指導我任何其他可以達到我目的的方式,但我不想為此目的使用任何第三方工具。
1 回答

蕭十郎
TA貢獻1815條經驗 獲得超13個贊
我認為您在 ajax 中發送了錯誤的數據。在你的“$ .ajax”調用中試試這個:
data: { 'rowid': rowid }
如果請求顯示任何錯誤,請嘗試檢查瀏覽控制臺。在您的 ajax 調用中,您只檢查成功返回,而不是失敗。
- 1 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消