S
S
Sergey2016-02-28 18:47:15
PHP
Sergey, 2016-02-28 18:47:15

How to display some data from an array via AJAX?

Good afternoon, dear experts)
The bottom line is the following. There is a loop with a nested loop, they should display a large number of photos per page. Data is entered through the ACF plugin.

<?php foreach($rows as $row) { ?>
        <div class="flexslider slider-album">
            <ul class="slides">
                <?php foreach ($row['albums_image'] as $image_album) { ?>
                    <li>
                        <img src="<?php echo $image_album['sizes']['album-image']; ?>">
                    </li>
                <?php } ?>
            </ul>
        </div>
    <?php } ?>


Is it possible to somehow organize the output of data from this cycle through AJAX, but not all at once, but step by step, first the data from one pass of the cycle is displayed, the cycle stops, then it is necessary to somehow display the second step of the cycle, etc., it would also be very well nested the cycle is also displayed not all at once, but step by step, for example, by clicking on the slider arrow.

I climbed on the Internet, there is no page pagination in the ACF plugin, you can display either all at once or by interrupting the cycle, display part of the data, but how can it be resumed later to display the rest of the data?

Maybe somehow it is possible to make pagination for this cycle?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-02-28
@sergafon

Solved the problem in the following way.

<?php
    $i = 0;
    foreach($rows as $row) { if ($i == 1) { ?>
        <div class="flexslider slider-album">
            <ul class="slides">
                <?php foreach ($row['albums_image'] as $image_album) { ?>
                    <li>
                        <img src="<?php echo $image_album['sizes']['album-image']; ?>">
                    </li>
                <?php } ?>
            </ul>
        </div>

    <?php } $i++; } ?>

instead of one, I will pass the number I need to the condition through AJAX, and display the desired iteration of the loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question