Good day. The question is what actually can not implement the article. There is a main page, it’s like a tile with an image and a short description, when you click on one of them a div (pop-up) appears and it displays more specific information of the tile you clicked on, it all works without refreshing the page. I just do not display anything at all with select.php!

index.php

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#popup1").hide(); var nav, content; nav = $('.item'); content = $('.o-post'); nav.find('a').on('click', function(e) { var href = $(this).attr('href'); history.pushState(null, null, href); $("#popup1").show(); e.preventDefault(); var data = { id: id }; var res = JSON.stringify(data); $.ajax({ url: "select.php", type: "GET", data: { data: res }, dataType: "json", success: function(response){ content.html(response); } }); }); $("#hide-post").click(function() { $("#popup1").hide(); }); }); </script> <div class="b-popup" id="popup1"> <div class="b-popup-content"> <img src="./icons/close.png" id="hide-post" style="cursor: pointer; float: right;"> <div class="o-post"></div> </div> </div> 

select.php

  <?php include('connect.php'); $post_sql = mysqli_query($CONNECT, "SELECT * FROM images WHERE id='$_GET[id]'"); while($post_row = mysqli_fetch_array($post_sql)) { echo '<img src="./img/user_images/'.$post_row['image'].'" width="500px" id="image-post"><p>'.$post_row['description'].'</p>'; } ?> 
  • Before writing a while you need to make sure that something has come up from the database at all ............. besides, json should return, judging by the ajax setting, and you are pushing out html .... ............ And as soon as only one line was output via echo it is sent as a response to the AJAX and everything, the remaining iterations will not work, the conclusion: you need to put everything into a variable at the beginning and only then give it as an answer - Alexey Shimansky
  • @ Alexey Shimansky, there’s probably ajax problem, because select.php worked, I changed content.html (response) to content.json (response), but it still doesn’t work - red_space
  • Because you do not understand what you are doing. And here incomprehensible content.json? From which ceiling did it come from? - Alexey Shimansky
  • one
    @ AlekseyShimansky I just study, and I don’t understand a lot of things, if you know how to make it work, help) - red_space
  • one
    in my first comment everything is actually written already. it remains only to apply it .... either dataType: "html", should be either echo json_decode(YOUR_CONTENT) ...... look for what the dataType and what it means for example jquery.page2page.ru/index.php5/… .......... well, and other points that I described - check / execute - Alexey Shimansky

0