0

I installed this script: https://www.webslesson.info/2017/03/load-content-while-scrolling-with-jquery-ajax-php.html

it works well but I have a problem with Bootstrap I can't align the columns

I modified the code in the while loop with this:

echo '<div class="border box col-3 m-1 mx-auto p-2 rounded text-center">';
echo '&nbsp;&nbsp;<span>'. $row['post_title'] .'</span>&nbsp;&nbsp;<br />';
echo '<span class="small">'. $row['post_description'] .'<br />'. $row['post_author'] .'</span>';
echo '</div>';

And I modified the index.php file to add two divs with a class 1 container & 1 row In theory the result should look like this:

Result.1 | Result.2 | Result.3 | Result.4

Result.5 | Result.6 | Result.7 | Result.8

etc ... But instead I have this:

  1. Result.1
  2. Result.2
  3. Result.3
  4. Result.4

etc ...

I'm looking for it but I can't find where the problem comes from when I test in HTML without PHP & AJAX the divs are displayed well next to each other and not below each other so the problem lies elsewhere.

7
  • Columns need to be put into a row element to work properly. Try and add that class to the #load_data element, and see how it looks then.
    – C3roe
    Commented Jan 20, 2023 at 9:55
  • If I understand correctly you are telling me to add the class row to the div which has id #load_data I have already tried the divs align well but the page no longer loads the other elements
    – Emma Lang
    Commented Jan 20, 2023 at 11:45
  • Not sure what exactly is going on, there is too little context here. Maybe try and add a .row div after the #load_data_message element, and then change the JS code to $('#load_data .row').append(data); and see if that helps ...
    – C3roe
    Commented Jan 20, 2023 at 12:00
  • Its good ! I found thank you for giving me the way. I added this: $('#load_data').addClass('row'); to the Ajax code as well as a series of four <br /> in the HTML code & everything works fine. It's a real Chinese puzzle when you don't know. I'm not a pro, I'm doing this for a personal site
    – Emma Lang
    Commented Jan 20, 2023 at 12:13
  • the sequence of <br /> in the html code is not sufficient when I enlarge the browser I think it comes from a height ratio of the load_data_message button I am looking for how to place it much lower I am going to do some test in css but I think the best is to retouch the Ajax Window Scroll code if someone knows better, help would be welcome, thank you
    – Emma Lang
    Commented Jan 20, 2023 at 12:30

0

Browse other questions tagged or ask your own question.