Всем здравствуйте! Есть список тем, которые выводятся циклом на php на веб-странице. (Картинка+название) Нужно чтобы при нажатии на на картинку выходило модальное окно с таким же id как и у нажатой темы, но при нажатии открывается пустое модальное окно Файл index.php PHP: <html> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="temp/default/js/bootstrap.min.js"></script> <script src="temp/default/js/SmoothScroll.js"></script> <script src="temp/default/js/theme-scripts.js"></script> <!---<link href="temp/default/css/bootstrap.min.css" rel="stylesheet">---> <link href="temp/default/css/bootstrap.css" rel="stylesheet"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <?php require_once("class/config.class.php"); require_once("class/database.class.php"); require_once("class/templater.class.php"); require_once("class/templater.class.php"); require_once("json/index.php"); $tmp = new Templater(); $db = new DataBase(); $data = array( "{TITLE}" => "Переводчик в Вэньчжоу", ); {include 'temp/default/header.tpl';} {include 'temp/default/services.tpl';} echo "<section id='portfolio'>"; echo "<div class='container'>"; echo "<div class='row'>"; echo "<div class='col-lg-12 text-center'>"; echo "<div class='section-title'>"; echo "<h2>Тематики</h2>"; echo"<p>У нас есть большой опыт в сфере контроля качества по чжечжянской провинции.</p>"; echo "</div>"; echo "</div>"; echo "</div>"; $counter = 0; $db = mysqli_connect("localhost", "perevodchik", "winston1945", "wenzhoutran"); $result = mysqli_query($db, "SELECT * FROM tbl_topic ORDER BY id DESC"); $counter = 0; while ($row = mysqli_fetch_array($result)) { if ($counter%2==0){ print "<div class='row row-0-gutter'>"; } echo "<div class='col-md-6 col-0-gutter'>"; echo "<div class='ot-portfolio-item'>"; echo "<figure class='effect-bubba';>"; echo "<img class='img-responsive' src='wtadmin/topics/uploads/".$row['picProfile']."'/>"; echo "<figcaption>"; echo "<h2>".$row['topic']."</h2>"; echo "<a href='#' data-toggle='modal' data-target='#Modal-1' >Больше информации</a>"; echo "</figcaption>"; echo "</figure>"; echo "</div>"; echo "</div>"; if ($counter%2) { print "</div>"; } } echo "</section>"; {include 'temp/default/languages.tpl';} {include 'temp/default/footer.tpl';} print "<div class='modal fade' id='Modal-1' tabindex='-1' role='dialog' aria-labelledby='Modal-label-1'>"; echo "<div class='modal-dialog' role='document'>"; echo "<div class='modal-content'>"; echo "<div class='modal-header'>"; echo "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>"; echo "<span aria-hidden='true'>×</span>"; echo"</button>"; echo "<h4 class='modal-title' id='Modal-1'>".$row['topic']."</h4>"; echo "</div>"; echo "<div class='modal-body'>"; /*echo "<img src='".$row['picProfile']."' class='img-responsive' />";*/ echo "<p>".$row['description']."</p>"; echo "</div>"; echo "<div class='modal-footer'>"; echo "<button type='button' class='btn btn-default' data-dismiss='modal'>Закрыть</button>"; echo "</div>"; echo "</div>"; echo "</div>"; if ($counter%1){ print "</div>"; } ?> <script> /*must apply only after HTML has loaded */ $(document).ready(function () { $('#topic').on('show.bs.modal', function(e) { /* get data written in data-person-name field */ var topic = $(e.relatedTarget).data('topic'); /* append that to form our service url */ var jqxhr = $.getJSON("http://localhost/json/index.php?topic="+ topic, function(json) { /* this function is called when request finishes. The response is stored in this json object*/ /* we get the div that holds the header and put there the value of the "title" element */ $('#Modal-1 .modal-header .modal-title').html(json["topic"]); /* we get the modal-body div and put the content of the "data" key in our php */ $('#Modal-1 .modal-body').html(json["data"]); }); }); }); </script>; </body> </html> Файл json/index.php PHP: $topic = $_GET["tbl_topic"]; $description = $_GET["description"]; $text= array('title' => $topic . '', 'data' => '<em>.' '. $description .'</em>.''); echo json_encode($text, JSON_FORCE_OBJECT);